26 #include <Classes.hpp>
27 #include <Controls.hpp>
28 #include <StdCtrls.hpp>
30 #include <Buttons.hpp>
31 #include <ExtCtrls.hpp>
33 #include <Dialogs.hpp>
34 #include <Graphics.hpp>
35 #include <ComCtrls.hpp>
52 #pragma package(smart_init)
62 TTrain::TTrain(
int Caller,
int RearStartElementIn,
int RearStartExitPosIn, AnsiString InputCode,
int StartSpeedIn,
int MassIn,
double MaxRunningSpeedIn,
63 double MaxBrakeRateIn,
double PowerAtRailIn,
TTrainMode TrainModeIn,
TTrainDataEntry *TrainDataEntryPtrIn,
int RepeatNumberIn,
int IncrementalMinutesIn,
64 int IncrementalDigitsIn,
int SignallerMaxSpeedIn) : RearStartElement(RearStartElementIn), RearStartExitPos(RearStartExitPosIn), HeadCode(InputCode),
65 StartSpeed(StartSpeedIn), Mass(MassIn), MaxRunningSpeed(MaxRunningSpeedIn), MaxBrakeRate(MaxBrakeRateIn), PowerAtRail(PowerAtRailIn),
66 TrainMode(TrainModeIn), TrainDataEntryPtr(TrainDataEntryPtrIn), RepeatNumber(RepeatNumberIn), IncrementalMinutes(IncrementalMinutesIn),
67 IncrementalDigits(IncrementalDigitsIn), SignallerMaxSpeed(SignallerMaxSpeedIn)
78 AnsiString(RearStartExitPosIn) +
"," + AnsiString(InputCode) +
"," + AnsiString(StartSpeedIn) +
"," + AnsiString(MassIn) +
"," +
79 AnsiString(TrainModeIn));
123 for(
int x = 0; x < 4; x++)
132 for(
int x = 0; x < 4; x++)
141 for(
int x = 0; x < 4; x++)
146 for(
int x = 0; x < 4; x++)
150 for(
int x = 0; x < 3; x++)
187 for(
int x = 0; x < 4; x++)
234 throw Exception(
"Error in attempting to delete FrontCodePtr");
238 for(
int x = 0; x < 4; x++)
242 throw Exception(
"Error in attempting to delete BackgroundPtr[" + AnsiString(x) +
"]");
247 for(
int x = 0; x < 4; x++)
251 throw Exception(
"Error in attempting to delete HeadCodeGrPtr[" + AnsiString(x) +
"]");
280 int NextElementPosition, NextEntryPos, ElementLength, SpeedLimit;
346 bool TempDerail =
false;
392 else if((NextElementPosition > -1) && (NextEntryPos > -1))
463 throw Exception(
"Error, LeadElement Exit Connection is NotSet");
473 for(
int x = 0; x < 4; x++)
480 for(
int x = 0; x < 4; x++)
723 if((random(RandRange)) == 0)
738 int LockedVectorNumber;
975 if(BufferLocation ==
"")
980 if((BufferLocation ==
"") || (BufferLocation != ExpectedLocation))
1042 int NextElementPosition, NextEntryPos;
1066 NextElementPosition = -1;
1069 if((NextElementPosition > -1) && (NextEntryPos > -1))
1183 AnsiString StationName;
1194 throw Exception(
"Error - Stopped at through station but neither lead nor mid elements have a name");
1207 if((NextElementPosition > -1) && (NextEntryPos > -1))
1330 if(NextElementPosition > -1)
1367 AnsiString Loc =
"";
1368 bool LocNamed =
false;
1397 Loc =
"outside railway";
1429 NextElementPosition = -1;
1440 if((NextElementPosition > -1) && (NextEntryPos > -1) && !
SPADFlag)
1458 if((NextElementPosition > -1) && (NextEntryPos > -1))
1496 FirstPair.second).
GetELink() == TempELink))
1501 SecondPair.second).
GetELink() == TempELink))
1515 FirstPair.second).
GetELink() == TempELink))
1520 SecondPair.second).
GetELink() == TempELink))
1534 FirstPair.second).
GetELink() == TempELink))
1539 SecondPair.second).
GetELink() == TempELink))
1569 ContinuationAutoSigEntry.
RouteNumber = RouteNumber;
1572 int NewLastElement = 0, NewLastExitPos = 0;
1590 if(NewLastElement == -1)
1593 throw Exception(
"Error, Connection = -1 in Continuation loop in UpdateTrain");
1596 if(NewLastExitPos == -1)
1598 throw Exception(
"Error, ConnLinkPos = -1 in Continuation loop in UpdateTrain");
1600 LastElement = NewLastElement;
1601 LastExitPos = NewLastExitPos;
1604 if(CumDistance < 1200)
1610 int FirstDistance = 0;
1611 if(CumDistance >= 1200)
1613 FirstDistance = 100;
1617 FirstDistance = 1200 - CumDistance;
1619 if(FirstDistance < 100)
1621 FirstDistance = 100;
1647 if(VectorIT->RouteNumber == RouteNumber)
1694 LockedVectorNumber)))
1853 for(
int x = 0; x < 4; x++)
1860 for(
int x = 0; x < 4; x++)
1886 if((LeadElementTrainID > -1) && (LeadElementTrainID !=
TrainID))
1891 if(OtherTrainEntryPos == -1)
1893 throw Exception(
"Error - OtherTrainEntryPos not set");
1912 int OtherTrainID = -1;
1913 if((MidExitLinkNum == 1) || (MidExitLinkNum == 3) || (MidExitLinkNum == 7) || (MidExitLinkNum == 9))
2004 bool StopRequired =
false;
2017 int NextElementEntryPos = -1;
2018 int NextElementExitPos = -1;
2019 bool TrainOnNextElement =
false;
2020 bool StopSignalAtNextElement =
false;
2021 if(ForwardConnection)
2029 StopSignalAtNextElement = ((NextTrackElement.
Config[NextElementExitPos] ==
Signal) && (NextTrackElement.
Attribute == 0));
2032 if(TrainAtStopLinkPos1 || TrainAtStopLinkPos2 || (ForwardConnection && (TrainOnNextElement || StopSignalAtNextElement)))
2087 throw Exception(
"Error, Straddle shouldn't be LeadMid prior to resetting at exit from UpdateTrain");
2300 if(Code.Length() != 4)
2304 for(
int x = 1; x < 5; x++)
2311 for(
int x = 0; x < 4; x++)
2475 throw Exception(
"Error in GetOffsetValues - Link value wrong");
2488 if((EntryLink == 1) || (EntryLink == 2) || (EntryLink == 4) || (EntryLink == 7))
2503 AnsiString(
VOffset) +
"," + AnsiString(Element) +
"," + AnsiString(EntryPos) +
"," +
HeadCode);
2512 TRect SourceRect, DestRect;
2514 DestRect.init(0, 0, 8, 8);
2517 Graphics::TBitmap *TempGraphic =
new Graphics::TBitmap;
2519 TempGraphic->PixelFormat = pf8bit;
2520 TempGraphic->Width = 16;
2521 TempGraphic->Height = 16;
2527 TempGraphic->Transparent =
true;
2531 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2532 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2538 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2546 else if(TempElement.
SpeedTag == 89)
2550 else if(TempElement.
SpeedTag == 90)
2554 else if(TempElement.
SpeedTag == 91)
2558 else if(TempElement.
SpeedTag == 92)
2562 else if(TempElement.
SpeedTag == 93)
2566 else if(TempElement.
SpeedTag == 94)
2570 else if(TempElement.
SpeedTag == 95)
2574 TempGraphic->Transparent =
true;
2578 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2579 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2581 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2588 for(
int x = 0; x < 40; x++)
2603 TempGraphic->Transparent =
true;
2607 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2608 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2610 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2624 TempGraphic->Transparent =
true;
2628 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2629 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2633 TempGraphic->Canvas->Draw(0, 0, TempElement.
GraphicPtr);
2636 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2641 TempGraphic->Transparent =
true;
2645 int BDVectorPos = -1;
2654 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2659 TempGraphic->Transparent =
true;
2663 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2664 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2666 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2672 TempGraphic->Transparent =
true;
2676 TempGraphic->Canvas->Draw(0, 0, EXGraphicPtr);
2677 TempGraphic->Canvas->Draw(0, 0, EntryDirectionGraphicPtr);
2679 GraphicPtr->Canvas->CopyRect(DestRect, TempGraphic->Canvas, SourceRect);
2945 throw Exception(
"Error, same train on two different bridge tracks");
2991 AnsiString(EntryPos) +
"," +
HeadCode);
3008 throw Exception(
"Error, TrackVectorPosition set but not EntryPos in SetTrainElementID");
3027 AnsiString(EntryPos) +
"," +
HeadCode);
3036 throw Exception(
"Error, TrackVectorPosition set but not EntryPos in ResetTrainElementID");
3069 AnsiString(ElementEntryPos) +
"," + AnsiString(
HOffset) +
"," + AnsiString(
VOffset) +
"," + AnsiString(StraddleValue) +
"," +
HeadCode);
3070 int LockedVectorNumber;
3083 TRect SourceRect, DestRect;
3084 DestRect.init(0, 0, 8, 8);
3091 int FirstELink, SecondELink = -1;
3094 if(RoutePair2.first > -1)
3103 if(SecondELink == -1)
3105 throw Exception(
"Error - Second ELink should be set but isn't in PlotAlternativeTrackRouteGraphic [1]");
3110 throw Exception(
"Error - First & Second ELinks have same value in PlotAlternativeTrackRouteGraphic");
3120 Graphics::TBitmap *DestGraphic =
new Graphics::TBitmap;
3121 DestGraphic->PixelFormat = pf8bit;
3122 DestGraphic->Width = 8;
3123 DestGraphic->Height = 8;
3124 DestGraphic->Transparent =
true;
3127 DestGraphic->Canvas->CopyRect(DestRect, RouteElement.
GetRouteEXGraphicPtr()->Canvas, SourceRect);
3136 PrefDirElement, LockedVectorNumber))
3151 if(ElementEntryPos > 1)
3173 AnsiString(EntryPos) +
"," +
HeadCode);
3175 bool WrongRoute =
false;
3201 int LinkNumber = TrackElement.
Link[EntryPos];
3202 if((LinkNumber == 1) || (LinkNumber == 3) || (LinkNumber == 7) || (LinkNumber == 9))
3207 bool LogActionErrorCalled =
false;
3217 LogActionErrorCalled =
true;
3234 else if(LinkNumber == 3)
3242 LogActionErrorCalled =
true;
3259 else if(LinkNumber == 7)
3267 LogActionErrorCalled =
true;
3284 else if(LinkNumber == 9)
3292 LogActionErrorCalled =
true;
3324 else if((RouteElement.
GetELinkPos() == 2) && (EntryPos == 0) && PointsAtElement)
3329 else if((RouteElement.
GetELinkPos() == 0) && (EntryPos == 2) && PointsAtElement)
3339 else if((RouteElement.
GetXLinkPos() == 2) && (EntryPos == 0) && PointsAtElement)
3344 else if((RouteElement.
GetXLinkPos() == 0) && (EntryPos == 2) && PointsAtElement)
3353 throw Exception(
"Error, Element in route but no route found in CheckAndCancelRouteForWrongEndEntry");
3374 bool ColourError =
false, ColourError2 =
false;
3379 ColourError2 =
true;
3381 for(
int x = 0; x < 4; x++)
3386 ColourError2 =
true;
3392 "ERROR: Colour depth insufficient to display train colours properly. Please ensure that the 'safe' (web) palette of 256 colours can be displayed");
3396 for(
int x = 0; x < 4; x++)
3483 AnsiString(EntryPos) +
"," +
HeadCode);
3484 int EntryHalfLength, CurrentElementHalfLength, NextElementHalfLength, CumulativeLength = 0, CurrentTrackVectorPosition = TrackVectorPosition;
3485 int DistanceAtHalfBraking, DistanceAtThreeQuarterBraking, ExitPos, NextTrackVectorPosition, NextEntryPos;
3486 bool RedSignalFlag =
false, BuffersFlag =
false, StationFlag =
false, BuffersOrContinuationNowFlag =
false, ContinuationNextFlag =
false,
3487 TrainInFrontInSignallerModeFlag =
false;
3488 double LimitingSpeed, FrontElementMaxSpeed, MaxExitSpeedAtHalfBrakingSquared, MaxExitSpeedAtHalfBraking, NextSpeedLimit, TempBrakeRate;
3489 double ExitSpeedHalfSquared, ExitSpeedFullSquared;
3490 bool SignallerStopRequired =
false;
3501 if(CurrentTrackVectorPosition > -1)
3505 if((EntryPos == 0) || (EntryPos == 2))
3518 else if(EntryPos == 1)
3542 EntryHalfLength = CurrentElementHalfLength;
3547 throw Exception(
"Error - CurrentTrackVectorPosition < 0 in SetTrainMovementValues");
3551 throw Exception(
"Error - HalfLength or SpeedLimit < 0 in SetTrainMovementValues");
3598 FrontElementMaxSpeed = LimitingSpeed;
3628 double ExitSpeedAtMaxBraking;
3633 ExitSpeedAtMaxBraking = 0;
3643 if(ExitSpeedAtMaxBraking > LimitingSpeed)
3645 SpeedToUse = ExitSpeedAtMaxBraking;
3649 SpeedToUse = LimitingSpeed;
3664 RedSignalFlag =
false;
3665 BuffersFlag =
false;
3666 StationFlag =
false;
3667 BuffersOrContinuationNowFlag =
false;
3668 ContinuationNextFlag =
false;
3671 CumulativeLength += (2 * CurrentElementHalfLength);
3674 SignallerStopRequired =
true;
3696 bool StopRequired =
false;
3710 StationFlag =
false;
3716 BuffersOrContinuationNowFlag =
true;
3718 if(!BuffersOrContinuationNowFlag && !BuffersFlag && !StationFlag)
3722 if((EntryPos == 0) || (EntryPos == 2))
3744 if(NextTrackVectorPosition > -1)
3749 if((NextEntryPos == 0) || (NextEntryPos == 2))
3762 else if(NextEntryPos == 1)
3775 if(NextEntryPos > 1)
3789 throw Exception(
"Error - Trying to access NextTrackVectorPosition when none present in SetTrainMovementValues");
3801 RedSignalFlag =
true;
3823 TrainInFrontInSignallerModeFlag =
true;
3847 if(RedSignalFlag || BuffersFlag || StationFlag || TrainInFrontInSignallerModeFlag || SignallerStopRequired ||
StepForwardFlag)
3859 double MaxHalfSpeed;
3863 if(MaxHalfSpeedAtHalfBraking > FrontElementMaxSpeed)
3865 MaxHalfSpeed = FrontElementMaxSpeed;
3869 MaxHalfSpeed = MaxHalfSpeedAtHalfBraking;
3877 bool HalfSpeedLimited =
false;
3881 HalfSpeedLimited =
true;
3911 if(HalfSpeedLimited)
3936 if(SignallerStopRequired)
3952 int TempMaxExitSpeed;
3955 if(MaxExitSpeedAtHalfBrakingSquared < 10)
3957 MaxExitSpeedAtHalfBraking = 0;
3961 MaxExitSpeedAtHalfBraking = sqrt(MaxExitSpeedAtHalfBrakingSquared);
3965 if(MaxExitSpeedAtHalfBraking > FrontElementMaxSpeed)
3967 TempMaxExitSpeed = FrontElementMaxSpeed;
3971 TempMaxExitSpeed = MaxExitSpeedAtHalfBraking;
3983 if(ExitSpeedHalfSquared < 10)
3993 if(ExitSpeedFullSquared < 10)
4065 double DeltaRemainingTimeInSecs = 3.6 * RemainingDistance /
MaxExitSpeed;
4066 ExitTimeFull =
EntryTime + TDateTime((DeltaExitTimeToMaxInSecs + DeltaRemainingTimeInSecs) / 86400.0);
4090 double DeltaRemainingTimeInSecs = 3.6 * RemainingDistance /
MaxExitSpeed;
4091 ExitTimeHalf =
EntryTime + TDateTime((DeltaExitTimeToMaxInSecs + DeltaRemainingTimeInSecs) / 86400.0);
4101 if(!BuffersOrContinuationNowFlag)
4103 if(NextSpeedLimit < LimitingSpeed)
4105 LimitingSpeed = NextSpeedLimit;
4109 int TempMaxExitSpeed;
4113 if(MaxExitSpeedAtHalfBrakingSquared < 10)
4115 MaxExitSpeedAtHalfBraking = 0;
4119 MaxExitSpeedAtHalfBraking = sqrt(MaxExitSpeedAtHalfBrakingSquared);
4121 if(MaxExitSpeedAtHalfBraking > FrontElementMaxSpeed)
4123 TempMaxExitSpeed = FrontElementMaxSpeed;
4127 TempMaxExitSpeed = MaxExitSpeedAtHalfBraking;
4138 TempBrakeRate = ((
EntrySpeed *
EntrySpeed) - (LimitingSpeed * LimitingSpeed)) / 3.6 / 3.6 / 2 / CumulativeLength;
4151 if(!BuffersOrContinuationNowFlag)
4153 CurrentTrackVectorPosition = NextTrackVectorPosition;
4154 EntryPos = NextEntryPos;
4155 CurrentElementHalfLength = NextElementHalfLength;
4158 ContinuationNextFlag =
true;
4162 while(((CumulativeLength -
FrontElementLength) < DistanceAtHalfBraking) && ((!BuffersOrContinuationNowFlag && !ContinuationNextFlag) ||
4182 if(ExitSpeedHalfSquared < 10)
4192 if(ExitSpeedFullSquared < 10)
4255 double DeltaExitTimeToMaxInSecs;
4256 double DistanceToMax;
4265 DeltaExitTimeToMaxInSecs = 2 * EntryHalfLength * 3.6 /
EntrySpeed;
4267 DistanceToMax = EntryHalfLength;
4270 double DeltaRemainingTimeInSecs = 3.6 * RemainingDistance /
MaxExitSpeed;
4271 ExitTimeFull =
EntryTime + TDateTime((DeltaExitTimeToMaxInSecs + DeltaRemainingTimeInSecs) / 86400.0);
4288 double DeltaExitTimeToMaxInSecs;
4289 double DistanceToMax;
4298 DeltaExitTimeToMaxInSecs = 2 * EntryHalfLength * 3.6 /
EntrySpeed;
4300 DistanceToMax = EntryHalfLength / 2;
4303 double DeltaRemainingTimeInSecs = 3.6 * RemainingDistance /
MaxExitSpeed;
4304 ExitTimeHalf =
EntryTime + TDateTime((DeltaExitTimeToMaxInSecs + DeltaRemainingTimeInSecs) / 86400.0);
4315 if(ExitSpeedHalfSquared < 10)
4325 if(ExitSpeedFullSquared < 10)
4344 if((EntryPos == 0) || (EntryPos == 2))
4366 if(NextTrackVectorPosition > -1)
4368 int NextElementLength;
4369 if(NextEntryPos > 1)
4377 double NextStoppingSpeed = sqrt(3.6 * 3.6 * 2 *
BrakeRate * NextElementLength);
4513 if((Ptr->Command ==
"cdt") || (Ptr->FormatType ==
Repeat))
4517 if((Ptr->ArrivalTime > TDateTime(-1)) && (Ptr->LocationName == Name))
4526 if((Ptr->EventTime > TDateTime(-1)) && (Ptr->LocationName == Name) && (Ptr->Command ==
"pas"))
4551 int CurrentTrackVectorPosition =
LeadElement, NextTrackVectorPosition;
4569 CurrentTrackVectorPosition).
Attribute != 4))
4608 if((EntryPos == 0) || (EntryPos == 2))
4630 CurrentTrackVectorPosition = NextTrackVectorPosition;
4631 EntryPos = NextEntryPos;
4655 throw Exception(
"Error - failed to set ReturnVal in ClearToNextSignal()");
4679 bool PlatformFoundFlag =
false, StopRequired =
false, SkipRouteCheck =
false, RouteOrPartRouteSet =
false;
4680 int CurrentTrackVectorPosition =
LeadElement, NextTrackVectorPosition, ElementNumber = 0, Distance = 0;
4681 int RouteStartPosition;
4683 int PlatformPosition;
4685 int EntryPos =
LeadEntryPos, ExitPos, NextEntryPos, RouteID;
4701 if(Distance > (4000 + LeadElementDistance))
4724 if(OtherTrain.
LeadElement == CurrentTrackVectorPosition)
4727 if((OtherCommand ==
"Fjo") || (OtherCommand ==
"jbo") || (OtherCommand ==
"cdt") || (OtherCommand ==
"Frh") ||
4773 if(!PlatformFoundFlag)
4775 PlatformPosition = CurrentTrackVectorPosition;
4778 PlatformFoundFlag =
true;
4794 if((EntryPos == 0) || (EntryPos == 2))
4838 if(ElementNumber < 2)
4840 SkipRouteCheck =
true;
4844 SkipRouteCheck =
false;
4846 if(ElementNumber == 1)
4848 RouteStartPosition = CurrentTrackVectorPosition;
4858 if(ElementNumber > 1)
4862 RouteOrPartRouteSet =
true;
4866 RouteOrPartRouteSet =
false;
4869 if(!SkipRouteCheck && !RouteOrPartRouteSet)
4876 int ExitLink = CurrentTrackElement.
Link[ExitPos];
4877 if((ExitLink == 1) || (ExitLink == 3) || (ExitLink == 7) || (ExitLink == 9))
4889 Distance += CurrentTrackElement.
Length01;
4893 Distance += CurrentTrackElement.
Length23;
4895 NextTrackVectorPosition = CurrentTrackElement.
Conn[ExitPos];
4896 NextEntryPos = CurrentTrackElement.
ConnLinkPos[ExitPos];
4897 CurrentTrackVectorPosition = NextTrackVectorPosition;
4898 EntryPos = NextEntryPos;
4935 return(RepeatHeadCode);
4957 bool FrontValid =
false, RearValid =
false;
4958 TTrackElement FrontAdjacentTrackElement, RearAdjacentTrackElement;
4962 TrainToBeJoinedBy = NULL;
4976 int TrainToBeJoinedByID = -1;
4997 if((TrainToBeJoinedByID < 0) && RearValid)
5016 if(TrainToBeJoinedByID < 0)
5018 TrainToBeJoinedBy = NULL;
5023 if(!TrainToBeJoinedBy->
Stopped())
5025 TrainToBeJoinedBy = NULL;
5036 TDateTime TimetableNonRepeatTime,
bool Warning)
5071 AnsiString(ActionType) +
"," + LocationName +
"," +
HeadCode);
5072 AnsiString BaseLog =
"", WarningBaseLog =
"", PerfLog =
"", ActionLog =
"";
5073 int IntMinsLate = 0;
5078 ActionLog =
" arrived at ";
5087 ActionLog =
" terminated at ";
5092 ActionLog =
" departed from ";
5094 if(ActionType ==
Pass)
5096 ActionLog =
" passed ";
5100 ActionLog =
" created at ";
5102 if(ActionType ==
Enter)
5104 ActionLog =
" entered railway at ";
5106 if(ActionType ==
Leave)
5108 ActionLog =
" left railway at ";
5112 ActionLog =
" split from front to ";
5116 ActionLog =
" split from rear to ";
5120 ActionLog =
" joined by ";
5124 ActionLog =
" changed direction at ";
5128 ActionLog =
" became new service ";
5132 ActionLog =
" taken under signaller control at ";
5136 ActionLog =
" restored to timetable control at ";
5142 ActionLog =
" REMOVED FROM RAILWAY DUE TO CRASH at ";
5146 ActionLog =
" REMOVED FROM RAILWAY DUE TO DERAILMENT at ";
5150 ActionLog =
" REMOVED FROM RAILWAY at ";
5155 ActionLog =
" received signaller authority to proceed";
5159 ActionLog =
" received signaller authority to step forward";
5163 ActionLog =
" changed direction under signaller control at ";
5167 ActionLog =
" received signaller authority to pass red signal";
5171 ActionLog =
" received signaller instruction to stop";
5175 ActionLog =
" stopped on signaller instruction ";
5179 ActionLog =
" joined under signaller control by ";
5183 ActionLog =
" suffered an onboard power failure at ";
5187 ActionLog =
" failure repaired at ";
5191 ActionLog =
" left railway under signaller control at ";
5193 if(OtherHeadCode !=
"")
5195 OtherHeadCode +=
" at ";
5202 WarningBaseLog =
HeadCode + ActionLog + OtherHeadCode + LocationName;
5208 bool TimePerformance =
true;
5216 TimePerformance =
false;
5220 double MinsLate = ((double)(ActualTime -
GetTrainTime(1, TimetableNonRepeatTime))) * 1440;
5232 IntMinsLate = int(ceil(MinsLate));
5236 IntMinsLate = int(floor(MinsLate));
5238 if(IntMinsLate == 0)
5240 PerfLog =
" on time";
5242 else if(IntMinsLate == 1)
5244 PerfLog =
" 1 minute late";
5246 else if(IntMinsLate == -1)
5248 PerfLog =
" 1 minute early";
5250 else if(IntMinsLate > 1)
5252 PerfLog =
" " + AnsiString(IntMinsLate) +
" minutes late";
5254 else if(IntMinsLate < -1)
5256 int PosIntMinsLate = -IntMinsLate;
5257 PerfLog =
" " + AnsiString(PosIntMinsLate) +
" minutes early";
5259 if(LocationName.Pos(
'-') > 0)
5261 PerfLog =
"," + PerfLog;
5275 if((ActionType ==
Arrive) && (IntMinsLate == 0))
5279 else if((ActionType ==
Arrive) && (IntMinsLate > 0))
5284 else if((ActionType ==
Arrive) && (IntMinsLate < 0))
5289 else if((ActionType ==
Pass) && (IntMinsLate == 0))
5293 else if((ActionType ==
Pass) && (IntMinsLate > 0))
5298 else if((ActionType ==
Pass) && (IntMinsLate < 0))
5303 else if((ActionType ==
Depart) && (IntMinsLate == 0))
5307 else if((ActionType ==
Depart) && (IntMinsLate > 0))
5326 AnsiString LocName =
"";
5392 if(LocationName ==
"")
5396 int FirstNamedElementPos, SecondNamedElementPos, FirstNamedLinkedElementPos, SecondNamedLinkedElementPos;
5397 int RearTrainRearPosition, RearTrainFrontPosition, RearTrainExitPos;
5398 int FrontTrainRearPosition, FrontTrainFrontPosition, FrontTrainExitPos;
5402 if(LocationName !=
"")
5410 SecondNamedElementPos, FirstNamedLinkedElementPos, SecondNamedLinkedElementPos))
5415 SecondNamedElementPos, FirstNamedLinkedElementPos, SecondNamedLinkedElementPos))
5429 int LeadPosA = FirstNamedElementPos;
5430 int LeadPosB = FirstNamedLinkedElementPos;
5431 int LeadPosC = SecondNamedElementPos;
5432 int LeadPosD = SecondNamedLinkedElementPos;
5434 int LeadNumAtLoc = 0;
5451 if(LeadNumAtLoc < 4)
5455 SecondNamedLinkedElementPos))
5457 FirstNamedElementPos = LeadPosA;
5458 FirstNamedLinkedElementPos = LeadPosB;
5459 SecondNamedElementPos = LeadPosC;
5460 SecondNamedLinkedElementPos = LeadPosD;
5464 int MidNumAtLoc = 0;
5481 if(LeadNumAtLoc > MidNumAtLoc)
5484 FirstNamedElementPos = LeadPosA;
5485 FirstNamedLinkedElementPos = LeadPosB;
5486 SecondNamedElementPos = LeadPosC;
5487 SecondNamedLinkedElementPos = LeadPosD;
5501 throw Exception(
"Error - LocationName not set in FrontTrainSplit");
5511 FrontTrainFrontPosition = FirstNamedLinkedElementPos;
5512 FrontTrainRearPosition = FirstNamedElementPos;
5513 RearTrainFrontPosition = SecondNamedElementPos;
5514 RearTrainRearPosition = SecondNamedLinkedElementPos;
5518 FrontTrainFrontPosition = SecondNamedLinkedElementPos;
5519 FrontTrainRearPosition = SecondNamedElementPos;
5520 RearTrainFrontPosition = FirstNamedElementPos;
5521 RearTrainRearPosition = FirstNamedLinkedElementPos;
5528 FrontTrainFrontPosition = SecondNamedLinkedElementPos;
5529 FrontTrainRearPosition = SecondNamedElementPos;
5530 RearTrainFrontPosition = FirstNamedElementPos;
5531 RearTrainRearPosition = FirstNamedLinkedElementPos;
5535 FrontTrainFrontPosition = FirstNamedLinkedElementPos;
5536 FrontTrainRearPosition = FirstNamedElementPos;
5537 RearTrainFrontPosition = SecondNamedElementPos;
5538 RearTrainRearPosition = SecondNamedLinkedElementPos;
5541 RearTrainExitPos = -1;
5542 for(
int x = 0; x < 4; x++)
5546 RearTrainExitPos = x;
5550 if(RearTrainExitPos == -1)
5552 throw Exception(
"Error - RearTrainRearPosition not linked to RearTrainFrontPosition in FrontTrainSplit");
5554 FrontTrainExitPos = -1;
5555 for(
int x = 0; x < 4; x++)
5559 FrontTrainExitPos = x;
5563 if(FrontTrainExitPos == -1)
5565 throw Exception(
"Error - FrontTrainRearPosition not linked to FrontTrainFrontPosition in FrontTrainSplit");
5568 int TrainIDOnRearOfRearTrain, TrainIDOnFrontOfRearTrain, TrainIDOnRearOfFrontTrain, TrainIDOnFrontOfFrontTrain;
5575 else if((RearMostElement.
TrackType ==
Bridge) && (RearTrainExitPos < 2))
5595 else if((FrontMostElement.
TrackType ==
Bridge) && (FrontTrainExitPos < 2))
5603 if(((TrainIDOnRearOfRearTrain > -1) && (TrainIDOnRearOfRearTrain !=
TrainID)) || ((TrainIDOnFrontOfRearTrain > -1) && (TrainIDOnFrontOfRearTrain !=
TrainID)
5604 ) || ((TrainIDOnRearOfFrontTrain > -1) && (TrainIDOnRearOfFrontTrain !=
TrainID)) ||
5605 ((TrainIDOnFrontOfFrontTrain > -1) && (TrainIDOnFrontOfFrontTrain !=
TrainID)))
5702 if(LocationName ==
"")
5706 int FirstNamedElementPos, SecondNamedElementPos, FirstNamedLinkedElementPos, SecondNamedLinkedElementPos;
5707 int RearTrainRearPosition, RearTrainFrontPosition, RearTrainExitPos;
5708 int FrontTrainRearPosition, FrontTrainFrontPosition, FrontTrainExitPos;
5712 if(LocationName !=
"")
5719 SecondNamedLinkedElementPos))
5723 SecondNamedLinkedElementPos))
5737 int LeadPosA = FirstNamedElementPos;
5738 int LeadPosB = FirstNamedLinkedElementPos;
5739 int LeadPosC = SecondNamedElementPos;
5740 int LeadPosD = SecondNamedLinkedElementPos;
5742 int LeadNumAtLoc = 0;
5759 if(LeadNumAtLoc < 4)
5763 SecondNamedLinkedElementPos))
5765 FirstNamedElementPos = LeadPosA;
5766 FirstNamedLinkedElementPos = LeadPosB;
5767 SecondNamedElementPos = LeadPosC;
5768 SecondNamedLinkedElementPos = LeadPosD;
5772 int MidNumAtLoc = 0;
5789 if(LeadNumAtLoc > MidNumAtLoc)
5792 FirstNamedElementPos = LeadPosA;
5793 FirstNamedLinkedElementPos = LeadPosB;
5794 SecondNamedElementPos = LeadPosC;
5795 SecondNamedLinkedElementPos = LeadPosD;
5809 throw Exception(
"Error - LocationName not set in RearTrainSplit");
5819 FrontTrainFrontPosition = FirstNamedLinkedElementPos;
5820 FrontTrainRearPosition = FirstNamedElementPos;
5821 RearTrainFrontPosition = SecondNamedElementPos;
5822 RearTrainRearPosition = SecondNamedLinkedElementPos;
5826 FrontTrainFrontPosition = SecondNamedLinkedElementPos;
5827 FrontTrainRearPosition = SecondNamedElementPos;
5828 RearTrainFrontPosition = FirstNamedElementPos;
5829 RearTrainRearPosition = FirstNamedLinkedElementPos;
5836 FrontTrainFrontPosition = SecondNamedLinkedElementPos;
5837 FrontTrainRearPosition = SecondNamedElementPos;
5838 RearTrainFrontPosition = FirstNamedElementPos;
5839 RearTrainRearPosition = FirstNamedLinkedElementPos;
5843 FrontTrainFrontPosition = FirstNamedLinkedElementPos;
5844 FrontTrainRearPosition = FirstNamedElementPos;
5845 RearTrainFrontPosition = SecondNamedElementPos;
5846 RearTrainRearPosition = SecondNamedLinkedElementPos;
5849 RearTrainExitPos = -1;
5850 for(
int x = 0; x < 4; x++)
5854 RearTrainExitPos = x;
5858 if(RearTrainExitPos == -1)
5860 throw Exception(
"Error - RearTrainRearPosition not linked to RearTrainFrontPosition in RearTrainSplit");
5862 FrontTrainExitPos = -1;
5863 for(
int x = 0; x < 4; x++)
5867 FrontTrainExitPos = x;
5871 if(FrontTrainExitPos == -1)
5873 throw Exception(
"Error - FrontTrainRearPosition not linked to FrontTrainFrontPosition in RearTrainSplit");
5876 int TrainIDOnRearOfRearTrain, TrainIDOnFrontOfRearTrain, TrainIDOnRearOfFrontTrain, TrainIDOnFrontOfFrontTrain;
5883 else if((RearMostElement.
TrackType ==
Bridge) && (RearTrainExitPos < 2))
5903 else if((FrontMostElement.
TrackType ==
Bridge) && (FrontTrainExitPos < 2))
5911 if(((TrainIDOnRearOfRearTrain > -1) && (TrainIDOnRearOfRearTrain !=
TrainID)) || ((TrainIDOnFrontOfRearTrain > -1) && (TrainIDOnFrontOfRearTrain !=
TrainID)
5912 ) || ((TrainIDOnRearOfFrontTrain > -1) && (TrainIDOnRearOfFrontTrain !=
TrainID)) ||
5913 ((TrainIDOnFrontOfFrontTrain > -1) && (TrainIDOnFrontOfFrontTrain !=
TrainID)))
6052 TTrain *TrainToBeJoinedBy;
6085 double OtherBrakeForce = TrainToBeJoinedBy->
MaxBrakeRate * TrainToBeJoinedBy->
Mass;
6087 double CombinedBrakeRate = (OtherBrakeForce + OwnBrakeForce) / (TrainToBeJoinedBy->
Mass +
Mass);
6144 int RouteNumber = -1;
6152 bool FirstPass =
true;
6157 if(FirstPass && (TVPos2 != FirstRouteElementVecPos))
6260 for(
int x = 0; x < IncNum; x++)
6293 else if(Ptr->
Command ==
"jbo")
6304 throw Exception(
"Error - illegal command in SendMissedActionLogs for IncNum = " + AnsiString(IncNum) +
", and command = " + Ptr->
Command);
6310 bool IncludeFER =
false;
6318 if(!IncludeFER && (Ptr->
Command ==
"Fer"))
6323 else if(IncludeFER && (Ptr->
Command ==
"Fer"))
6334 else if(Ptr->
Command ==
"Fjo")
6340 else if(Ptr->
Command ==
"Frh")
6350 else if(Ptr->
Command ==
"Frh-sh")
6401 else if(Ptr->
Command ==
"jbo")
6406 else if(Ptr->
Command ==
"cdt")
6414 throw Exception(
"Error - illegal command in SendMissedActionLogs for IncNum = " + AnsiString(IncNum) +
", and command = " + Ptr->
Command);
6786 int RouteNumber = -1;
6794 bool FirstPass =
true;
6799 if(FirstPass && (TVPos2 != FirstRouteElementVecPos))
6827 ",FloatingLabelNextString" +
"," +
HeadCode);
6828 AnsiString RetStr =
"", LocationName =
"";
6832 throw Exception(
"Error - start entry in FloatingLabelNextString");
6872 else if(Ptr->
Command ==
"Fns")
6878 else if(Ptr->
Command ==
"F-nshs")
6909 RetStr =
"None, train terminated at " + Ptr->
LocationName;
6911 else if(Ptr->
Command ==
"Frh")
6913 RetStr =
"None, train terminated at " + Ptr->
LocationName;
6915 else if(Ptr->
Command ==
"Fer")
6917 AnsiString AllowedExits =
"";
6920 else if(Ptr->
Command ==
"Fjo")
6925 else if(Ptr->
Command ==
"jbo")
6930 else if(Ptr->
Command ==
"fsp")
6935 else if(Ptr->
Command ==
"rsp")
6940 else if(Ptr->
Command ==
"cdt")
6953 + AnsiString(RptNum) +
",CheckNewServiceDepartureTime," +
HeadCode);
6954 AnsiString DepTime =
"", EventTime =
"";
6955 bool CDTFlag =
false;
6959 if(AVI->Command ==
"cdt")
6964 if((AVI->Command ==
"fsp") || (AVI->Command ==
"rsp"))
6967 RetStr +=
"\nNew service splits at " + EventTime;
6971 if(AVI->Command ==
"jbo")
6974 RetStr +=
"\nNew service joined by " + AVI->OtherHeadCode +
" at " + EventTime;
6978 if((AVI->FormatType ==
TimeLoc) && (AVI->DepartureTime > TDateTime(-1)))
6983 RetStr +=
"\nNew service changes direction then departs at " + DepTime;
6987 RetStr +=
"\nNew service departs at " + DepTime;
7003 ",FloatingTimetableString" +
"," +
HeadCode);
7004 AnsiString RetStr =
"", PartStr =
"";
7010 throw Exception(
"Error - start entry in FloatingTimetableString");
7013 bool FirstPass =
true;
7026 AnsiString TrainLoc =
"";
7064 AnsiString TrainLoc =
"";
7092 else if(Ptr->
Command ==
"Fns")
7098 else if(Ptr->
Command ==
"F-nshs")
7131 else if(Ptr->
Command ==
"Frh")
7135 else if(Ptr->
Command ==
"Fer")
7137 AnsiString AllowedExits =
"";
7140 else if(Ptr->
Command ==
"Fjo")
7145 else if(Ptr->
Command ==
"jbo")
7150 else if(Ptr->
Command ==
"fsp")
7155 else if(Ptr->
Command ==
"rsp")
7160 else if(Ptr->
Command ==
"cdt")
7166 RetStr = RetStr +
'\n' + PartStr;
7183 RetStr =
"Timetable finished";
7187 RetStr =
"No timetable";
7344 bool ForwardHeadCode;
7348 ForwardHeadCode =
true;
7353 ForwardHeadCode =
false;
7496 if(ColourNumber == 0)
7500 else if(ColourNumber == 1)
7504 else if(ColourNumber == 2)
7508 else if(ColourNumber == 3)
7512 else if(ColourNumber == 4)
7516 else if(ColourNumber == 5)
7520 else if(ColourNumber == 6)
7524 else if(ColourNumber == 7)
7528 else if(ColourNumber == 8)
7532 else if(ColourNumber == 9)
7536 else if(ColourNumber == 10)
7540 else if(ColourNumber == 11)
7544 else if(ColourNumber == 12)
7548 else if(ColourNumber == 13)
7552 else if(ColourNumber == 14)
7564 for(
int x = 0; x < 4; x++)
7571 for(
int x = 0; x < 4; x++)
7656 if((LocationAndMarker[1] !=
'*') && (LocationAndMarker.Length() > 6))
7659 AnsiString Location = LocationAndMarker.SubString(1, LocationAndMarker.Length() - 6);
7660 bool GiveMessagesFalse =
false;
7661 bool CheckLocationsExistInRailwayTrue =
true;
7668 AnsiString Marker = LocationAndMarker.SubString(LocationAndMarker.Length() - 5, 6);
7671 if(Marker[6] ==
'1')
8136 bool HideFlashingTrain =
true;
8139 Graphics::TBitmap *SmallTrainBitmap;
8180 HideFlashingTrain =
false;
8185 HideFlashingTrain =
false;
8190 HideFlashingTrain =
false;
8195 HideFlashingTrain =
false;
8200 HideFlashingTrain =
false;
8204 if((
LeadElement > -1) && (!HideFlashingTrain || Flash))
8208 if((
MidElement > -1) && (!HideFlashingTrain || Flash))
8232 for(
int y = 0; y < 3; y++)
8236 bool FoundFlag =
false;
8247 if(IMPair.first != IMPair.second)
8274 if((LocationName ==
"") && (
MidElement > -1))
8278 if((LocationName ==
"") && (
LagElement > -1))
8282 if(LocationName ==
"")
8284 throw Exception(
"Error - Location name not set in TrainAtLocation");
8295 for(
int x = 0; x < 4; x++)
8307 for(
int x = 0; x < 4; x++)
8324 AnsiString(LinkNumber) +
"," +
HeadCode);
8375 int DistanceToRedSignal = 0;
8376 float TimeToAct = 0;
8377 float MinsEarly = 0;
8378 TDateTime DepartureTime;
8424 float CurrentStopTime;
8425 float LaterStopTime;
8426 float RecoverableTime;
8431 if(DistanceToRedSignal == -1)
8450 float TimeToSubtract, TotalStopTime;
8453 TimeToSubtract = RecoverableTime;
8489 if(CurrentStopTime > 0)
8491 TotalStopTime = CurrentStopTime + LaterStopTime;
8500 else if((MinsEarly > 0) && !
Stopped())
8502 TotalStopTime = LaterStopTime + MinsEarly;
8506 if(LaterStopTime == 0)
8508 TotalStopTime = CurrentStopTime;
8514 TotalStopTime = CurrentStopTime + LaterStopTime - TimeToSubtract;
8517 if(AvTrackSpeed < 30)
8521 int Speed = AvTrackSpeed;
8531 TimeToAct = TotalStopTime + DistanceToRedSignal * 3.6 / 60 / Speed;
8553 if((NextEntryPos == 0) || (NextEntryPos == 2))
8673 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
8716 int IncrementalMinutes = 0;
8717 int IncrementalDigits = 0;
8725 throw Exception(
"Error - Repeat entry && less than two trains for Snt entry: " + TDEntry.
HeadCode);
8754 if(AVEntry0.
Command ==
"Snt-sh")
8759 int IncrementalMinutes = 0;
8760 int IncrementalDigits = 0;
8768 throw Exception(
"Error - Repeat entry && less than two trains for Snt-sh entry: " + TDEntry.
HeadCode);
8800 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
8860 AnsiString Loc =
"";
8861 bool ElementFound =
false;
8866 ElementFound =
true;
8871 ElementFound =
true;
8876 ElementFound =
true;
8905 else if(AVEntryPtr->
Command ==
"Fer")
8907 bool CorrectExit =
false;
9015 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9030 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9045 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9056 bool TTrainController::AddTrain(
int Caller,
int RearPosition,
int FrontPosition, AnsiString HeadCode,
int StartSpeed,
int Mass,
double MaxRunningSpeed,
9057 double MaxBrakeRate,
double PowerAtRail, AnsiString ModeStr,
TTrainDataEntry *TrainDataEntryPtr,
int RepeatNumber,
int IncrementalMinutes,
9058 int IncrementalDigits,
int SignallerSpeed,
bool SignallerControl,
TActionEventType &EventType)
9060 LogEvent(AnsiString(Caller) +
",AddTrain," + AnsiString(RearPosition) +
"," + AnsiString(FrontPosition) +
"," + HeadCode +
"," + AnsiString(StartSpeed) +
9061 "," + AnsiString(Mass) +
"," + ModeStr);
9063 "," + HeadCode +
"," + AnsiString(StartSpeed) +
"," + AnsiString(Mass) +
"," + ModeStr +
"," + HeadCode);
9065 int RearExitPos = -1;
9067 for(
int x = 0; x < 4; x++)
9074 if(RearExitPos == -1)
9076 throw Exception(
"Error, RearExit == -1 in AddTrain");
9078 bool ReportFlag =
true;
9095 if(ModeStr ==
"Timetable")
9101 if(MaxRunningSpeed < 10)
9103 MaxRunningSpeed = 10;
9105 if(SignallerSpeed < 10)
9107 SignallerSpeed = 10;
9109 TTrain *NewTrain =
new TTrain(0, RearPosition, RearExitPos, HeadCode, StartSpeed, Mass, MaxRunningSpeed, MaxBrakeRate, PowerAtRail, TrainMode,
9110 TrainDataEntryPtr, RepeatNumber, IncrementalMinutes, IncrementalDigits, SignallerSpeed);
9115 if(SignallerControl)
9145 if(!SignallerControl)
9160 if(!SignallerControl)
9171 AnsiString Loc =
"";
9188 if(!SignallerControl)
9207 int RouteNumber = -1;
9208 bool SignalsSet =
false;
9215 int RouteStartPosition;
9219 if(FirstPair.first == RouteNumber)
9221 RouteStartPosition = FirstPair.second;
9223 else if(SecondPair.first == RouteNumber)
9225 RouteStartPosition = SecondPair.second;
9229 throw Exception(
"Error, RouteNumber not found in Route2MultiMap in 1st of 2 calls to SetAllRearwardsSignals in AddTrain");
9235 else if(RouteNumber > -1)
9255 int LinkedRouteNumber = -1;
9276 int RouteStartPosition;
9280 if(FirstPair.first == RouteNumber)
9282 RouteStartPosition = FirstPair.second;
9284 else if(SecondPair.first == RouteNumber)
9286 RouteStartPosition = SecondPair.second;
9290 throw Exception(
"Error, RouteNumber not found in Route2MultiMap in 2nd of 2 calls to SetAllRearwardsSignals in AddTrain");
9296 else if(RouteNumber > -1)
9316 int LinkedRouteNumber = -1;
9337 AnsiString(TrackVectorNumber));
9340 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9349 throw Exception(
"Error, VecPos not set in EntryPos");
9351 if(
TrainVectorAt(2, VecPos).LeadElement == TrackVectorNumber)
9356 else if(
TrainVectorAt(4, VecPos).MidElement == TrackVectorNumber)
9361 else if(
TrainVectorAt(6, VecPos).LagElement == TrackVectorNumber)
9375 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9383 throw Exception(
"Error - No Train identified in TrainVectorAtIdent with ID = " + AnsiString(TrainID));
9393 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
9423 AnsiString RetStr =
"", PartStr =
"";
9431 if((Ptr->Command !=
"") && (Ptr->Command[1] ==
'S'))
9439 if(Ptr->SignallerControl)
9441 RetStr =
"Train under signaller control";
9446 if(Ptr->ArrivalTime == Ptr->DepartureTime)
9457 else if((Ptr->FormatType ==
TimeLoc) && (Ptr->ArrivalTime != TDateTime(-1)))
9461 else if((Ptr->FormatType ==
TimeLoc) && (Ptr->ArrivalTime == TDateTime(-1)))
9465 else if(Ptr->FormatType ==
PassTime)
9469 else if(Ptr->Command ==
"Fns")
9475 else if(Ptr->Command ==
"F-nshs")
9478 Ptr->NonRepeatingShuttleLinkHeadCode +
" at " + Ptr->LocationName;
9485 else if((Ptr->Command ==
"Fns-sh") && (RepNum < (TTDEPtr->
NumberOfTrains - 1)))
9492 else if((Ptr->Command ==
"Fns-sh") && (RepNum >= (TTDEPtr->
NumberOfTrains - 1)))
9495 Ptr->NonRepeatingShuttleLinkHeadCode, +
" at " + Ptr->LocationName;
9498 else if((Ptr->Command ==
"Frh-sh") && (RepNum < (TTDEPtr->
NumberOfTrains - 1)))
9505 else if((Ptr->Command ==
"Frh-sh") && (RepNum >= (TTDEPtr->
NumberOfTrains - 1)))
9507 PartStr =
"Terminate at " + Ptr->LocationName;
9509 else if(Ptr->Command ==
"Frh")
9511 PartStr =
"Terminate at " + Ptr->LocationName;
9513 else if(Ptr->Command ==
"Fer")
9515 AnsiString AllowedExits;
9519 else if(Ptr->Command ==
"Fjo")
9522 Ptr->OtherHeadCode, RepNum, IncDig) +
" at " + Ptr->LocationName;
9524 else if(Ptr->Command ==
"jbo")
9527 (50, Ptr->OtherHeadCode, RepNum, IncDig) +
" at " + Ptr->LocationName;
9529 else if(Ptr->Command ==
"fsp")
9534 else if(Ptr->Command ==
"rsp")
9539 else if(Ptr->Command ==
"cdt")
9545 RetStr = RetStr +
'\n' + PartStr;
9553 while(Ptr < TTDEPtr->ActionVector.end() && (Count < 33) && ((Ptr->Command ==
"") || ((Ptr->Command !=
"") && (Ptr->Command[1] !=
'F'))));
9566 + AnsiString(RptNum) +
",ControllerCheckNewServiceDepartureTime," + TDEPtr->
HeadCode);
9567 AnsiString DepTime =
"", EventTime =
"";
9568 bool CDTFlag =
false;
9572 if(AVI->Command ==
"cdt")
9577 if((AVI->Command ==
"fsp") || (AVI->Command ==
"rsp"))
9580 RetStr +=
"\nNew service splits at " + EventTime;
9584 if(AVI->Command ==
"jbo")
9587 RetStr +=
"\nNew service joined by " + AVI->OtherHeadCode +
" at " + EventTime;
9591 if((AVI->FormatType ==
TimeLoc) && (AVI->DepartureTime > TDateTime(-1)))
9596 RetStr +=
"\nNew service changes direction then departs at " + DepTime;
9600 RetStr +=
"\nNew service departs at " + DepTime;
9759 ActiveTrackElementNameMapEntry.first =
Track->
TrackVector.at(x).ActiveTrackElementName;
9760 ActiveTrackElementNameMapEntry.second = 0;
9766 std::ifstream TTBLFile(FileName, std::ios_base::binary);
9769 if(TTBLFile.is_open())
9771 char *TrainTimetableString =
new char[10000];
9773 bool EndOfFile =
false;
9776 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
9778 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
9785 delete[] TrainTimetableString;
9789 AnsiString OneLine(TrainTimetableString);
9790 bool FinalCallFalse =
false;
9791 while((Count == 0) && !
ProcessOneTimetableLine(5, Count, OneLine, EndOfFile, FinalCallFalse, GiveMessages, CheckLocationsExistInRailway))
9795 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
9796 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
9801 TimetableMessage(GiveMessages,
"Timetable invalid - unable to find a valid start time on its own line");
9803 delete[] TrainTimetableString;
9807 OneLine = AnsiString(TrainTimetableString);
9813 TTBLFile.getline(TrainTimetableString, 10000,
'\0');
9815 if(TTBLFile.eof() && (TrainTimetableString[0] ==
'\0'))
9825 OneLine = AnsiString(TrainTimetableString);
9827 if(OneLine.Length() > 9999)
9829 TimetableMessage(GiveMessages,
"Timetable contains a line that is too long - 10,000 or more characters!");
9831 delete[] TrainTimetableString;
9835 bool FinalCallFalse =
false;
9836 if(!
ProcessOneTimetableLine(6, Count, OneLine, EndOfFile, FinalCallFalse, GiveMessages, CheckLocationsExistInRailway))
9840 delete[] TrainTimetableString;
9844 if(EndOfFile && (Count < 2))
9847 TimetableMessage(GiveMessages,
"Timetable has too few or no relevant entries - must have a start time on its own line and at least one train");
9849 delete[] TrainTimetableString;
9855 delete[] TrainTimetableString;
9860 TimetableMessage(GiveMessages,
"Failed to open timetable file, make sure it's not open in another application");
9871 bool CheckLocationsExistInRailway)
9996 AnsiString((
short)FinalCall) +
"," + AnsiString((
short)CheckLocationsExistInRailway));
10006 if(OneLine[1] !=
'*')
10008 int SCPos = OneLine.Pos(
';');
10019 bool AllCommas =
true;
10021 for(
int x = 1; x < OneLine.Length() + 1; x++)
10023 if(OneLine[x] !=
',')
10028 if(AllCommas || (OneLine ==
""))
10043 AnsiString First =
"", Second =
"", Third =
"", Fourth =
"";
10044 int RearStartOrRepeatMins = 0, FrontStartOrRepeatDigits = 0, NumberOfRepeats = 0;
10045 TDateTime EventTime(0), ArrivalTime(0), DepartureTime(0);
10046 TDateTime StartTime(0);
10048 bool Warning =
false;
10075 AnsiString TrainInfoStr =
"", HeadCode =
"", Description =
"";
10076 int StartSpeed = 0, MaxRunningSpeed = 0, Mass = 0;
10077 double MaxBrakeRate = 0;
10078 double PowerAtRail = 0;
10079 int SignallerSpeed = 0;
10080 if(OneLine[1] ==
'*')
10086 int Pos = OneLine.Pos(
',');
10089 int SubStringLength = 20;
10090 if(OneLine.Length() < 20)
10092 SubStringLength = OneLine.Length();
10094 TimetableMessage(GiveMessages,
"Error in timetable - entry incomplete: see '" + OneLine.SubString(1, SubStringLength) +
"'....");
10098 TrainInfoStr = OneLine.SubString(1, Pos - 1);
10099 if(!
SplitTrainInfo(0, TrainInfoStr, HeadCode, Description, StartSpeed, MaxRunningSpeed, Mass, MaxBrakeRate, PowerAtRail, SignallerSpeed,
10109 TempTrainDataEntry.
HeadCode = HeadCode;
10113 TempTrainDataEntry.
Mass = Mass;
10121 AnsiString NewRemainder = OneLine.SubString(Pos + 1, OneLine.Length() - Pos);
10124 while(NewRemainder[NewRemainder.Length()] ==
',')
10126 if(NewRemainder.Length() > 1)
10128 NewRemainder = NewRemainder.SubString(1, NewRemainder.Length() - 1);
10137 if(NewRemainder ==
"")
10139 TimetableMessage(GiveMessages,
"Error in timetable - no events following train: '" + OneLine +
"'");
10144 int CommaCount = 0;
10145 for(
int x = 1; x < NewRemainder.Length() + 1; x++)
10147 if(NewRemainder[x] ==
',')
10152 if(CommaCount == 0)
10154 if((NewRemainder.SubString(7, 3) !=
"Snt") || (NewRemainder[NewRemainder.Length()] !=
'S'))
10156 int SubStringLength = 20;
10157 if(OneLine.Length() < 20)
10159 SubStringLength = OneLine.Length();
10162 "Error in timetable - must have at least a start and a finish event for a train that is not started under signaller control - see line beginning: '" +
10163 OneLine.SubString(1, SubStringLength) +
"'....");
10168 AnsiString OneEntry =
"";
10173 bool FinishFlag =
false;
10174 for(
int x = 0; x < CommaCount + 1; x++)
10176 if((CommaCount == 0) || (x < CommaCount))
10181 if(CommaCount == 0)
10183 OneEntry = NewRemainder;
10188 Pos = NewRemainder.Pos(
',');
10189 OneEntry = NewRemainder.SubString(1, Pos - 1);
10190 NewRemainder = NewRemainder.SubString(Pos + 1, NewRemainder.Length() - Pos);
10196 RearStartOrRepeatMins = 0;
10197 FrontStartOrRepeatDigits = 0;
10198 NumberOfRepeats = 0;
10199 if(!
SplitEntry(0, OneEntry, GiveMessages, CheckLocationsExistInRailway, First, Second, Third, Fourth, RearStartOrRepeatMins,
10200 FrontStartOrRepeatDigits, FormatType, LocationType, SequenceType, ShuttleLinkType, ExitList, Warning))
10202 TimetableMessage(GiveMessages,
"Error in timetable - Event: '" + OneEntry +
"'");
10207 if(Warning && (Second ==
"Frh"))
10209 TimetableMessage(GiveMessages,
"Error in line - '" + OneEntry +
"': warnings cannot be given for 'Frh' events");
10213 if(Warning && (Second ==
"Fjo"))
10216 "': warnings cannot be given for 'Fjo' events, for a train join warning add a 'W' prefix to the 'jbo' event");
10222 if(SequenceType !=
Start)
10224 TimetableMessage(GiveMessages,
"Error in timetable - First event not a start event: '" + OneEntry +
"'");
10228 if((Second ==
"Snt") && (Fourth ==
'S') && (NewRemainder !=
""))
10230 if(NewRemainder[1] !=
'R')
10233 "Error in timetable - the only event that can follow a train created under signaller control is a repeat, see '" +
10239 if((Second ==
"Snt") || (Second ==
"Snt-sh"))
10243 if((HeadCode ==
"") || (Description ==
"") || (MaxRunningSpeed == 0) || (Mass == 0) || (MaxBrakeRate == 0))
10246 TimetableMessage(GiveMessages,
"Error in timetable - train information incomplete before 'Snt' or 'Snt-sh' start event: '" +
10252 if((Second ==
"Sfs") || (Second ==
"Sns") || (Second ==
"Sns-sh") || (Second ==
"Sns-fsh"))
10257 TimetableMessage(GiveMessages,
"Error in timetable - headcode missing before 'Sfs', 'Sns', 'Sns-sh' or 'Sns-fsh' start event: '" +
10262 if((StartSpeed != 0) || (MaxRunningSpeed != 0) || (Mass != 0) || (MaxBrakeRate != 0) || (PowerAtRail != 0))
10265 "Error in timetable - information additional to a headcode & optional description given before 'Sfs', 'Sns', 'Sns-sh' or 'Sns-fsh' start event: '" +
10272 if(SequenceType ==
Finish)
10281 TDateTime TempTime;
10287 ActionVectorEntry.
Warning = Warning;
10303 ActionVectorEntry.
Command = Second;
10318 else if(FormatType ==
TimeCmd)
10324 ActionVectorEntry.
Command = Second;
10332 ActionVectorEntry.
Command = Second;
10333 ActionVectorEntry.
ExitList = ExitList;
10341 ActionVectorEntry.
Command = Second;
10355 ActionVectorEntry.
Command = Second;
10366 ActionVectorEntry.
Command = Second;
10376 ActionVectorEntry.
Command = Second;
10385 ActionVectorEntry.
Command = Second;
10394 ActionVectorEntry.
Command = Second;
10400 ActionVectorEntry.
Command = Second;
10402 TempTrainDataEntry.
ActionVector.push_back(ActionVectorEntry);
10407 OneEntry = NewRemainder;
10412 RearStartOrRepeatMins = 0;
10413 FrontStartOrRepeatDigits = 0;
10414 NumberOfRepeats = 0;
10415 if((FinishFlag) && (OneEntry[1] !=
'R'))
10418 TimetableMessage(GiveMessages,
"Error in timetable - Last event = '" + OneEntry +
"'. An earlier finish event has been found with something other than a repeat following it - only a repeat can follow a finish event.");
10422 if(OneEntry[1] !=
'R')
10424 if(!
SplitEntry(1, OneEntry, GiveMessages, CheckLocationsExistInRailway, First, Second, Third, Fourth, RearStartOrRepeatMins,
10425 FrontStartOrRepeatDigits, FormatType, LocationType, SequenceType, ShuttleLinkType, ExitList, Warning))
10427 TimetableMessage(GiveMessages,
"Error in timetable - Event: '" + OneEntry +
"'");
10431 if(SequenceType !=
Finish)
10433 TimetableMessage(GiveMessages,
"Error in timetable - last event should be a finish: '" + OneEntry +
"'");
10440 TDateTime TempTime;
10446 ActionVectorEntry.
Warning = Warning;
10453 ActionVectorEntry.
Command = Second;
10461 ActionVectorEntry.
Command = Second;
10470 ActionVectorEntry.
Command = Second;
10479 ActionVectorEntry.
Command = Second;
10489 ActionVectorEntry.
Command = Second;
10490 ActionVectorEntry.
ExitList = ExitList;
10494 ActionVectorEntry.
Command = Second;
10496 TempTrainDataEntry.
ActionVector.push_back(ActionVectorEntry);
10501 if(!
SplitRepeat(0, OneEntry, RearStartOrRepeatMins, FrontStartOrRepeatDigits, NumberOfRepeats, GiveMessages))
10517 TempTrainDataEntry.
ActionVector.push_back(ActionVectorEntry);
10536 if((HeadCode[HeadCode.Length() - 1] <
'0') || (HeadCode[HeadCode.Length() - 1] >
'9'))
10541 if((HeadCode[HeadCode.Length()] <
'0') || (HeadCode[HeadCode.Length()] >
'9'))
10556 if(TimeStr.Length() < 5)
10561 if((TimeStr[1] <
'0') || (TimeStr[1] >
'9'))
10566 if((TimeStr[2] <
'0') || (TimeStr[2] >
'9'))
10571 if(TimeStr[3] !=
':')
10576 if((TimeStr[4] <
'0') || (TimeStr[4] >
'5'))
10581 if((TimeStr[5] <
'0') || (TimeStr[5] >
'9'))
10586 while(TimeStr.Length() > 5)
10588 TimeStr = TimeStr.SubString(1, TimeStr.Length() - 1);
10590 double WholeHours = (AnsiString(TimeStr[1]) + AnsiString(TimeStr[2])).ToDouble();
10591 double FracHour = ((AnsiString(TimeStr[4]) + AnsiString(TimeStr[5])).ToDouble()) / 60.0;
10593 if((WholeHours + FracHour) >= 95.98334)
10598 Time = TDateTime((WholeHours + FracHour) / 24);
10605 bool TTrainController::SplitEntry(
int Caller, AnsiString OneEntry,
bool GiveMessages,
bool CheckLocationsExistInRailway, AnsiString &First, AnsiString &Second,
10606 AnsiString &Third, AnsiString &Fourth,
int &RearStartOrRepeatMins,
int &FrontStartOrRepeatDigits,
TTimetableFormatType &FormatType,
10615 TDateTime TempTime;
10617 if(OneEntry.Length() > 0)
10619 if(OneEntry[1] ==
'W')
10622 OneEntry = OneEntry.SubString(2, OneEntry.Length() - 1);
10626 if(OneEntry ==
"Frh")
10636 if(OneEntry.Length() < 7)
10641 int Pos = OneEntry.Pos(
';');
10649 First = OneEntry.SubString(1, 5);
10655 AnsiString Remainder = OneEntry.SubString(Pos + 1, OneEntry.Length() - Pos);
10657 if((Remainder[1] >=
'0') && (Remainder[1] <=
'9'))
10660 if(Remainder.Length() < 7)
10665 Pos = Remainder.Pos(
';');
10672 Second = Remainder.SubString(1, 5);
10678 Third = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
10691 Pos = Remainder.Pos(
';');
10694 Second = Remainder;
10695 if(Second ==
"cdt")
10720 if((Pos != 4) && (Pos != 7) && (Pos != 8))
10726 Second = Remainder.SubString(1, Pos - 1);
10728 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
10730 Pos = Remainder.Pos(
';');
10737 Third = Remainder.SubString(1, Pos - 1);
10738 Fourth = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
10740 if((Second ==
"Snt") || (Second ==
"Snt-sh"))
10743 int SpacePos = Third.Pos(
' ');
10749 AnsiString RearStartStr = Third.SubString(1, SpacePos - 1);
10750 AnsiString FrontStartStr = Third.SubString(SpacePos + 1, Third.Length() - SpacePos);
10752 if(CheckLocationsExistInRailway)
10762 if(Second ==
"Snt")
10765 SequenceType =
Start;
10774 SequenceType =
Start;
10785 if(Second ==
"Sns-sh")
10789 SequenceType =
Start;
10804 if(Second ==
"F-nshs")
10818 if(Second ==
"Sns-fsh")
10822 SequenceType =
Start;
10832 if(Second ==
"Fns-sh")
10852 if(Second ==
"pas")
10867 if(Second ==
"Fer")
10874 if(CheckLocationsExistInRailway)
10886 if((Second !=
"Fns") && (Second !=
"Fjo") && (Second !=
"jbo") && (Second !=
"fsp") && (Second !=
"rsp") && (Second !=
"Sfs") && (Second !=
"Sns") &&
10887 (Second !=
"Frh-sh"))
10899 if(Second ==
"Frh-sh")
10907 if((Second ==
"Fns") || (Second ==
"Fjo") || (Second ==
"Frh-sh"))
10911 if((Second ==
"jbo") || (Second ==
"fsp") || (Second ==
"rsp"))
10915 if((Second ==
"Sfs") || (Second ==
"Sns"))
10917 SequenceType =
Start;
10935 if((LocStr[1] >=
'0') && (LocStr[1] <=
'9'))
10940 for(
int x = 1; x < LocStr.Length() + 1; x++)
10942 if(LocStr[x] <
' ')
10947 if(LocStr[x] >
'z')
10954 if(CheckLocationsExistInRailway)
10959 "' appears in the timetable but is not a valid name. To be valid the name must be a stopping location and apply to one or more platforms " +
10960 "(not concourses on their own), or to track at a blue non-station named location. BUT NOTE THAT trains can't stop at continuations so a name " +
10961 "that includes a continuation will not be valid.");
10979 if((HeadCode.Length() < 4) || (HeadCode.Length() > 8))
10982 "', length must be between 4 and 8 characters, and last 4 must be a legitimate headcode. This error can also be caused by omitting a service reference after Snt-sh, Sns-sh, Fns-sh or Frh-sh");
10987 for(
int x = 1; x < (HeadCode.Length() + 1); x++)
10989 if((HeadCode[x] <
' ') || (HeadCode[x] >
'~'))
10991 TimetableMessage(GiveMessages,
"Non-printable character in headcode '" + HeadCode +
"'");
10997 for(
int x = 3; x >= 0; x--)
10999 if(((HeadCode[HeadCode.Length() - x] <
'A') || (HeadCode[HeadCode.Length() - x] >
'Z')) && ((HeadCode[HeadCode.Length() - x] <
'a') ||
11000 (HeadCode[HeadCode.Length() - x] >
'z')) && ((HeadCode[HeadCode.Length() - x] <
'0') || (HeadCode[HeadCode.Length() - x] >
'9')))
11002 TimetableMessage(GiveMessages,
"Headcode error in '" + HeadCode +
"', headcode must consist of letters and digits only");
11018 AnsiString CurrentID =
"";
11020 if(IDSet.Length() == 0)
11022 TimetableMessage(GiveMessages,
"Must have at least one exit element ID following 'Fer'");
11026 for(
int x = 1; x <= IDSet.Length(); x++)
11029 if(((C <
'0') || (C >
'9')) && (C !=
' ') && (C !=
'N') && (C !=
'-'))
11031 TimetableMessage(GiveMessages,
"Illegal character in the set of element IDs following 'Fer' in '" + IDSet +
"'");
11036 int Pos = IDSet.Pos(
' ');
11047 CurrentID = IDSet.SubString(1, Pos - 1);
11048 IDSet = IDSet.SubString(Pos + 1, IDSet.Length() - Pos);
11060 TimetableMessage(GiveMessages,
"The element ID '" + CurrentID +
"' following 'Fer' is not an exit");
11067 if(!ExitList.empty())
11071 if(*ELIT == VecPos)
11073 TimetableMessage(GiveMessages,
"The element ID '" + CurrentID +
"' following 'Fer' duplicates an earlier element");
11080 ExitList.push_back(VecPos);
11090 Pos = IDSet.Pos(
' ');
11097 int &Mass,
double &MaxBrakeRate,
double &PowerAtRail,
int &SignallerSpeed,
bool GiveMessages)
11104 AnsiString Remainder =
"";
11105 int SemiColonCount = 0;
11107 for(
int x = 1; x < TrainInfoStr.Length() + 1; x++)
11109 if(TrainInfoStr[x] ==
';')
11114 if((SemiColonCount != 6) && (SemiColonCount != 7) && (SemiColonCount != 1) && (SemiColonCount != 0))
11116 TimetableMessage(GiveMessages,
"Error in train information in '" + TrainInfoStr +
11117 "'. Should be headcode + optional description for a continuing service;" +
11118 " or headcode, description, start speed, max running speed, mass, brake force, power (and optional signaller max. speed) for a new service");
11122 if(SemiColonCount == 0)
11124 HeadCode = TrainInfoStr;
11133 if(SemiColonCount == 1)
11135 Pos = TrainInfoStr.Pos(
';');
11136 HeadCode = TrainInfoStr.SubString(1, Pos - 1);
11137 Description = TrainInfoStr.SubString(Pos + 1, TrainInfoStr.Length() - Pos);
11143 if(Description ==
"")
11145 TimetableMessage(GiveMessages,
"Train description missing in '" + TrainInfoStr +
"'");
11149 if(Description.Length() > 60)
11151 TimetableMessage(GiveMessages,
"Train description too long, limit of 60 characters '" + TrainInfoStr +
"'");
11155 for(
int x = 1; x < Description.Length() + 1; x++)
11157 if((Description[x] <
' ') || (Description[x] >
'~'))
11159 TimetableMessage(GiveMessages,
"Train description contains invalid characters in '" + TrainInfoStr +
"'");
11168 Pos = TrainInfoStr.Pos(
';');
11169 HeadCode = TrainInfoStr.SubString(1, Pos - 1);
11170 Remainder = TrainInfoStr.SubString(Pos + 1, TrainInfoStr.Length() - Pos);
11176 Pos = Remainder.Pos(
';');
11177 Description = Remainder.SubString(1, Pos - 1);
11178 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11179 if(Description ==
"")
11181 TimetableMessage(GiveMessages,
"Train description missing in '" + TrainInfoStr +
"'");
11185 if(Description.Length() > 60)
11187 TimetableMessage(GiveMessages,
"Train description too long, limit of 60 characters '" + TrainInfoStr +
"'");
11191 for(
int x = 1; x < Description.Length() + 1; x++)
11193 if((Description[x] <
' ') || (Description[x] > 126))
11195 TimetableMessage(GiveMessages,
"Train description contains invalid characters in '" + TrainInfoStr +
"'");
11200 Pos = Remainder.Pos(
';');
11201 AnsiString StartSpeedStr = Remainder.SubString(1, Pos - 1);
11203 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11204 if(StartSpeedStr ==
"")
11206 TimetableMessage(GiveMessages,
"Train starting speed missing in '" + TrainInfoStr +
"'");
11210 for(
int x = 1; x < StartSpeedStr.Length() + 1; x++)
11212 if((StartSpeedStr[x] <
'0') || (StartSpeedStr[x] >
'9'))
11214 TimetableMessage(GiveMessages,
"Train start speed contains invalid characters in '" + TrainInfoStr +
"'");
11219 StartSpeed = StartSpeedStr.ToInt();
11225 TimetableMessage(GiveMessages,
"Train starting speed > 400km/h in '" + TrainInfoStr +
"'. Setting it to 400km/h");
11229 Pos = Remainder.Pos(
';');
11230 AnsiString MaxRunningSpeedStr = Remainder.SubString(1, Pos - 1);
11232 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11233 if(MaxRunningSpeedStr ==
"")
11235 TimetableMessage(GiveMessages,
"Train maximum running speed missing in '" + TrainInfoStr +
"'");
11239 for(
int x = 1; x < MaxRunningSpeedStr.Length() + 1; x++)
11241 if((MaxRunningSpeedStr[x] <
'0') || (MaxRunningSpeedStr[x] >
'9'))
11243 TimetableMessage(GiveMessages,
"Train maximum running speed contains invalid characters in '" + TrainInfoStr +
"'");
11248 MaxRunningSpeed = MaxRunningSpeedStr.ToInt();
11254 TimetableMessage(GiveMessages,
"Train maximum running speed > 400km/h in '" + TrainInfoStr +
"'. Setting it to 400km/h");
11258 if(MaxRunningSpeed < 10)
11261 MaxRunningSpeed = 10;
11264 TimetableMessage(GiveMessages,
"Train maximum running speed can't be less than 10km/h in '" + TrainInfoStr +
"', it will be set to 10km/h");
11268 Pos = Remainder.Pos(
';');
11269 AnsiString MassStr = Remainder.SubString(1, Pos - 1);
11271 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11274 TimetableMessage(GiveMessages,
"Train mass missing in '" + TrainInfoStr +
"'");
11278 for(
int x = 1; x < MassStr.Length() + 1; x++)
11280 if((MassStr[x] <
'0') || (MassStr[x] >
'9'))
11282 TimetableMessage(GiveMessages,
"Train mass contains invalid characters in '" + TrainInfoStr +
"'");
11287 Mass = MassStr.ToInt() * 1000;
11293 TimetableMessage(GiveMessages,
"Train mass > 10,000 tonnes in '" + TrainInfoStr +
"'. Setting it to 10,000 tonnes");
11299 TimetableMessage(GiveMessages,
"Train mass zero in '" + TrainInfoStr +
"'");
11303 Pos = Remainder.Pos(
';');
11304 AnsiString MaxBrakeForceStr = Remainder.SubString(1, Pos - 1);
11306 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11307 if(MaxBrakeForceStr ==
"")
11309 TimetableMessage(GiveMessages,
"Train braking force missing in '" + TrainInfoStr +
"'");
11313 for(
int x = 1; x < (MaxBrakeForceStr.Length() + 1); x++)
11315 if((MaxBrakeForceStr[x] !=
'.') && ((MaxBrakeForceStr[x] <
'0') || (MaxBrakeForceStr[x] >
'9')))
11317 TimetableMessage(GiveMessages,
"Train braking force contains invalid characters in '" + TrainInfoStr +
"'");
11322 double MaxBrakeForce = MaxBrakeForceStr.ToDouble() * 1000;
11325 if((MaxBrakeForce / Mass) > 1)
11327 MaxBrakeForce = Mass;
11330 TimetableMessage(GiveMessages,
"Train braking force too high in '" + TrainInfoStr +
"'. Setting it to the same as the train mass");
11334 if((MaxBrakeForce / Mass) < 0.01)
11336 MaxBrakeForce = Mass * 0.01;
11339 TimetableMessage(GiveMessages,
"Train braking force too low in '" + TrainInfoStr +
"'. Setting it to 1% of the train mass");
11344 MaxBrakeRate = MaxBrakeForce / Mass * 9.81;
11346 AnsiString GrossPowerStr =
"", SignallerSpeedStr =
"";
11348 if(SemiColonCount == 6)
11350 GrossPowerStr = Remainder;
11351 SignallerSpeedStr =
"30";
11355 Pos = Remainder.Pos(
';');
11356 GrossPowerStr = Remainder.SubString(1, Pos - 1);
11357 SignallerSpeedStr = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11360 if(GrossPowerStr ==
"")
11362 TimetableMessage(GiveMessages,
"Train power missing in '" + TrainInfoStr +
"'");
11366 for(
int x = 1; x < GrossPowerStr.Length() + 1; x++)
11368 if((GrossPowerStr[x] <
'0') || (GrossPowerStr[x] >
'9'))
11370 TimetableMessage(GiveMessages,
"Train power contains invalid characters in '" + TrainInfoStr +
"'");
11376 double GrossPower = GrossPowerStr.ToInt() * 1000;
11383 TimetableMessage(GiveMessages,
"Train power > 100,000kW in '" + TrainInfoStr +
"'. Setting it to 100,000kW");
11387 else if(GrossPower == 0)
11392 else if((GrossPower > 0) && (GrossPower < 10000))
11395 GrossPower = 10000;
11397 PowerAtRail = GrossPower * 0.8;
11401 if(SignallerSpeedStr ==
"")
11403 TimetableMessage(GiveMessages,
"Signaller speed not set in '" + TrainInfoStr +
"', either set a value or remove the extra semicolon");
11407 for(
int x = 1; x < SignallerSpeedStr.Length() + 1; x++)
11409 if((SignallerSpeedStr[x] <
'0') || (SignallerSpeedStr[x] >
'9'))
11411 TimetableMessage(GiveMessages,
"Signaller speed contains invalid characters in '" + TrainInfoStr +
"'");
11416 SignallerSpeed = SignallerSpeedStr.ToInt();
11422 TimetableMessage(GiveMessages,
"Signaller speed > 400km/h in '" + TrainInfoStr +
"'. Setting it to 400km/h");
11426 if(SignallerSpeed < 10)
11429 SignallerSpeed = 10;
11432 TimetableMessage(GiveMessages,
"Signaller speed can't be less than 10km/h in '" + TrainInfoStr +
"', it will be set to 10km/h");
11450 if(OneEntry.Length() < 7)
11452 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - should be 'R;m;d;n'");
11456 int SemiColonCount = 0;
11458 for(
int x = 1; x < OneEntry.Length() + 1; x++)
11460 if(OneEntry[x] ==
';')
11465 if(SemiColonCount != 3)
11467 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - should be 'R;m;d;n'");
11471 if((OneEntry[1] !=
'R') || (OneEntry[2] !=
';'))
11473 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - should be 'R;m;d;n'");
11477 AnsiString Remainder = OneEntry.SubString(3, OneEntry.Length() - 2);
11482 Pos = Remainder.Pos(
';');
11483 AnsiString MinutesStr = Remainder.SubString(1, Pos - 1);
11485 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11486 if(MinutesStr ==
"")
11488 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - minute increment segment missing");
11492 if(MinutesStr.Length() > 3)
11495 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - minute value too high, maximum value is 999");
11499 for(
int x = 1; x < MinutesStr.Length() + 1; x++)
11501 if((MinutesStr[x] <
'0') || (MinutesStr[x] >
'9'))
11503 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - non-digit character in minute increment segment");
11508 RearStartOrRepeatMins = MinutesStr.ToInt();
11509 if(RearStartOrRepeatMins == 0)
11511 TimetableMessage(GiveMessages,
"Repeat minute increment is zero in: '" + OneEntry +
"' - can't have a zero value");
11515 Pos = Remainder.Pos(
';');
11516 AnsiString DigitsStr = Remainder.SubString(1, Pos - 1);
11518 Remainder = Remainder.SubString(Pos + 1, Remainder.Length() - Pos);
11519 if(DigitsStr ==
"")
11521 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - headcode increment segment missing");
11525 for(
int x = 1; x < DigitsStr.Length() + 1; x++)
11527 if((DigitsStr[x] <
'0') || (DigitsStr[x] >
'9'))
11529 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - non-digit character in headcode increment segment");
11534 if(DigitsStr.Length() > 2)
11536 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - maximum number of digits for headcode increment is 2");
11540 FrontStartOrRepeatDigits = DigitsStr.ToInt();
11554 "' - a repeating service with incrementing digits must have digits as its last two headcode characters");
11558 AnsiString NumberStr = Remainder;
11560 if(NumberStr ==
"")
11562 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - number of repeats missing");
11566 if(NumberStr.Length() > 4)
11569 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - repeat value too high, no timetabled event can exceed 95 hours & 59 minutes");
11573 for(
int x = 1; x < NumberStr.Length() + 1; x++)
11575 if((NumberStr[x] <
'0') || (NumberStr[x] >
'9'))
11578 TimetableMessage(GiveMessages,
"Error in repeat: '" + OneEntry +
"' - non-digit character in number of repeats");
11583 NumberOfRepeats = NumberStr.ToInt();
11584 if(NumberOfRepeats == 0)
11586 TimetableMessage(GiveMessages,
"Number of repeats is zero in: '" + OneEntry +
"' - if no repeats are needed the repeat should be omitted");
11742 SecondPassMessage(GiveMessages,
"Error in timetable - there appear to be no train services in the timetable, it must contain at least one");
11765 SecondPassMessage(GiveMessages,
"Error in timetable - the following service has no listed events, there must be at least one: " + TDEntry.
HeadCode);
11779 SecondPassMessage(GiveMessages,
"Error in timetable - service must have a start event and at least one other for: " + TDEntry.
HeadCode);
11795 "Error in timetable - a signaller control service can have no more than one item (a repeat) after the start event, see: " +
11807 "Error in timetable - a signaller control service cannot have any other than a repeat after the start event, see: " + TDEntry.
HeadCode);
11834 SecondPassMessage(GiveMessages,
"Error in timetable - finish events Fns-sh and Frh-sh not permitted immediately after an Snt entry for: " +
11845 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
11850 SecondPassMessage(GiveMessages,
"Error in timetable - a start event is present that is not the first event for: " + TDEntry.
HeadCode);
11860 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
11865 SecondPassMessage(GiveMessages,
"Error in timetable - a repeat is present that is not the last item for: " + TDEntry.
HeadCode);
11875 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
11886 SecondPassMessage(GiveMessages,
"Error in timetable - the last item must be either a finish event or a repeat for: " + TDEntry.
HeadCode);
11896 SecondPassMessage(GiveMessages,
"Error in timetable - the last event before the repeat must be a finish for: " + TDEntry.
HeadCode);
11908 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
11915 SecondPassMessage(GiveMessages,
"Error in timetable - a finish event must be either the last or last but one for: " + TDEntry.
HeadCode);
11924 SecondPassMessage(GiveMessages,
"Error in timetable - the only event that can follow a finish event is a repeat for: " +
11944 if((AVEntry0.
Command ==
"Snt") || (AVEntry0.
Command ==
"Snt-sh"))
11946 AnsiString LocationName =
"";
11962 SecondPassMessage(GiveMessages,
"Error in timetable - stopped 'Snt' or 'Snt-sh' followed by an illegal event for: " +
11963 TDEntry.
HeadCode +
". The event isn't valid for a stationary train.");
11972 SecondPassMessage(GiveMessages,
"Error in timetable - 'Snt' or 'Snt-sh' event at stop location but start speed not zero for: " +
11981 if(AVEntry0.
Command ==
"Snt-sh")
11995 SecondPassMessage(GiveMessages,
"Error in timetable - unlocated 'Snt' not followed by 'Fer', 'pas' or an arrival for: " +
12011 SecondPassMessage(GiveMessages,
"Error in timetable - 'Sfs', 'Sns', 'Sns-sh' or 'Sns-fsh' followed by an illegal event for: " +
12012 TDEntry.
HeadCode +
". The event isn't valid for a stationary train.");
12023 bool FoundFlag =
false;
12029 for(
unsigned int y = 1; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12041 SecondPassMessage(GiveMessages,
"Error in timetable - no location departure following an 'Sfs', 'Sns', 'Sns-sh'or 'Sns-fsh' event for: " +
12054 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12063 ": an event should have had a location name associated with it but it could not be found");
12069 for(
unsigned int z = y + 1; z <
TrainDataVector.at(x).ActionVector.size(); z++)
12091 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12101 SecondPassMessage(GiveMessages,
"Error in timetable - only a repeat can follow a finish entry for: " + TDEntry.
HeadCode);
12108 if(AVEntry.
Command ==
"F-nshs")
12113 SecondPassMessage(GiveMessages,
"Error in timetable - F-nshs (shuttle link) must be the last event for: " + TDEntry.
HeadCode);
12141 SecondPassMessage(GiveMessages,
"Error in timetable - a jbo event is followed by an illegal event for: " + TDEntry.
HeadCode +
12142 ". The event isn't valid for a stationary train.");
12152 SecondPassMessage(GiveMessages,
"Error in timetable - a train split can't be the last event for: " + TDEntry.
HeadCode);
12160 SecondPassMessage(GiveMessages,
"Error in timetable - a train split is followed by an illegal event for: " + TDEntry.
HeadCode +
12161 ". The event isn't valid for a stationary train.");
12179 SecondPassMessage(GiveMessages,
"Error in timetable - a 'cdt' is followed by an illegal event for: " + TDEntry.
HeadCode +
12180 ". The event isn't valid for a stationary train.");
12190 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival and departure can't be the last event for: " + TDEntry.
HeadCode);
12198 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival and departure is followed by an illegal event for: " +
12199 TDEntry.
HeadCode +
". The event isn't valid for a moving train.");
12217 SecondPassMessage(GiveMessages,
"Error in timetable - a pass time is followed by an illegal event for: " + TDEntry.
HeadCode +
12218 ". The event isn't valid for a moving train.");
12240 bool LastEntryIsAnArrival =
false;
12247 LastEntryIsAnArrival =
false;
12248 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12255 throw Exception(
"Timetable error, TimeLoc times not as initially set for " + TDEntry.
HeadCode);
12257 if(LastEntryIsAnArrival)
12261 LastEntryIsAnArrival =
false;
12267 LastEntryIsAnArrival =
true;
12274 LastEntryIsAnArrival =
true;
12275 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12282 throw Exception(
"Timetable error, TimeLoc times not as initially set for " + TDEntry.
HeadCode);
12284 if(LastEntryIsAnArrival)
12288 LastEntryIsAnArrival =
false;
12294 LastEntryIsAnArrival =
true;
12304 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12312 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival can't be the last event for: " + TDEntry.
HeadCode);
12320 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival is followed by an illegal event for: " + TDEntry.
HeadCode +
12321 ". The event isn't valid for a stationary train.");
12332 SecondPassMessage(GiveMessages,
"Error in timetable - a timed departure can't be the last event for: " + TDEntry.
HeadCode);
12340 SecondPassMessage(GiveMessages,
"Error in timetable - a timed departure is followed by an illegal event for: " + TDEntry.
HeadCode +
12341 ". The event isn't valid for a moving train.");
12355 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12362 throw Exception(
"Timetable error, TimeLoc entry has EventTime not -1 for " + TDEntry.
HeadCode);
12366 throw Exception(
"Timetable error, TimeLoc entry has neither arrival nor departure time set for " + TDEntry.
HeadCode);
12373 throw Exception(
"Timetable error, TimeTimeLoc entry has EventTime not -1 for " + TDEntry.
HeadCode);
12377 throw Exception(
"Timetable error, TimeTimeLoc entry has either arrival or departure time not set for " + TDEntry.
HeadCode);
12386 throw Exception(
"Timetable error, Cmd or PassTime entry has EventTime not set for " + TDEntry.
HeadCode);
12390 throw Exception(
"Timetable error, Cmd or PassTime entry has either arrival or departure time set for " + TDEntry.
HeadCode);
12397 throw Exception(
"Timetable error, Repeat entry has a time set for " + TDEntry.
HeadCode);
12408 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12423 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival and departure has a later arrival than departure time for: " +
12431 SecondPassMessage(GiveMessages,
"Error in timetable - a timed arrival and departure has too early an arrival time for: " +
12446 SecondPassMessage(GiveMessages,
"Error in timetable - a timed location event has a time that is too early for: " + TDEntry.
HeadCode);
12458 SecondPassMessage(GiveMessages,
"Error in timetable - a timed location event has a time that is too early for: " + TDEntry.
HeadCode);
12470 SecondPassMessage(GiveMessages,
"Error in timetable - a train event has a time that is set too early for: " + TDEntry.
HeadCode +
12471 ", may be before timetable start time");
12482 AnsiString LastLocationName =
"";
12486 bool LastEntryIsAnArrival =
false;
12491 LastEntryIsAnArrival =
false;
12492 LastLocationName =
TrainDataVector.at(x).ActionVector.at(0).LocationName;
12493 if(LastLocationName !=
"")
12495 throw Exception(
"Timetable error, moving Snt entry has LocationName set for " + TDEntry.
HeadCode);
12497 for(
unsigned int y = 1; y <
TrainDataVector.at(x).ActionVector.size();
12510 SecondPassMessage(GiveMessages,
"Error in timetable - a location event is inconsistent for: " + TDEntry.
HeadCode +
" && " +
12522 SecondPassMessage(GiveMessages,
"Error in timetable - a location event is inconsistent for: " + TDEntry.
HeadCode +
" && " +
12534 ShowMessage(
"Two or more locations are the same without a change of direction between them. Please correct if this is an error.\n\nThis warning will not be shown again.");
12543 LastEntryIsAnArrival =
false;
12547 if(LastEntryIsAnArrival && (AVEntry.
LocationName != LastLocationName))
12550 "Error in timetable - a location event for a timed departure is different from the arrival location for: " + TDEntry.
HeadCode);
12555 else if(!LastEntryIsAnArrival && (AVEntry.
LocationName == LastLocationName))
12558 "Error in timetable - a location event for a timed arrival is the same as the earlier departure location for: " + TDEntry.
HeadCode);
12564 LastEntryIsAnArrival = !LastEntryIsAnArrival;
12570 LastEntryIsAnArrival =
true;
12571 LastLocationName =
TrainDataVector.at(x).ActionVector.at(0).LocationName;
12572 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12584 SecondPassMessage(GiveMessages,
"Error in timetable - a location event is inconsistent for: " + TDEntry.
HeadCode +
" && " +
12596 SecondPassMessage(GiveMessages,
"Error in timetable - a location event is inconsistent for: " + TDEntry.
HeadCode +
" && " +
12608 ShowMessage(
"Two or more locations are the same without a change of direction between them. Please correct if this is an error.\n\nThis warning will not be shown again.");
12617 LastEntryIsAnArrival =
false;
12621 if(LastEntryIsAnArrival && (AVEntry.
LocationName != LastLocationName))
12624 "Error in timetable - a location event for a timed departure is different from the arrival location for: " + TDEntry.
HeadCode);
12632 "A location event for a timed arrival is the same as the earlier departure location for: " + TDEntry.
HeadCode +
". Please correct if this is an error.\n\nThis warning will not be shown again.");
12639 LastEntryIsAnArrival = !LastEntryIsAnArrival;
12647 AnsiString LocationNameToBeChecked =
"";
12652 unsigned int y = 0;
12667 LocationNameToBeChecked = TDEntry.
ActionVector.at(y).LocationName;
12668 for(
unsigned int z = y; z < TDEntry.
ActionVector.size(); z++)
12686 for(
unsigned int a = z; a < TDEntry.
ActionVector.size(); a++)
12694 ShowMessage(
"Two or more locations are the same without a change of direction between them. Please correct if this is an error.\n\nThis warning will not be shown again.");
12713 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12718 throw Exception(
"Error, non- 'Snt', 'Fer' or Repeat entry doesn't have a location name set for " + TDEntry.
HeadCode);
12720 AnsiString LocName =
"";
12726 throw Exception(
"Error, 'Snt' entry at a stop location doesn't have a location name set for " + TDEntry.
HeadCode);
12733 throw Exception(
"Error, 'Snt' unlocated entry has a location name set for " + TDEntry.
HeadCode);
12756 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12781 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12803 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12825 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12844 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12847 if((AVEntry.
Command ==
"Sns-sh") || (AVEntry.
Command ==
"Snt-sh"))
12862 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12867 throw Exception(
"Error - timetable ActionVector entry no. " + AnsiString(y) +
" has FormatType unset for: " + TDEntry.
HeadCode);
12871 throw Exception(
"Error - timetable ActionVector entry no. " + AnsiString(y) +
" has SequenceType unset for: " + TDEntry.
HeadCode);
12875 throw Exception(
"Error - timetable ActionVector entry no. " + AnsiString(y) +
" has LocationType unset for: " + TDEntry.
HeadCode);
12879 throw Exception(
"Error - timetable ActionVector entry no. " + AnsiString(y) +
" has ShuttleLinkType unset for: " + TDEntry.
HeadCode);
12918 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12920 AnsiString LocName =
TrainDataVector.at(x).ActionVector.at(y).LocationName;
12926 SecondPassMessage(GiveMessages,
"Error in timetable - continuation names (" + LocName +
") must not be included, see service " + HC);
12939 int IncMinutes = 0;
12949 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
12955 SecondPassMessage(GiveMessages,
"Error in timetable - a repeat time exceeds 95h 59m, see service " + HC);
12961 if((
double)
TrainDataVector.at(x).ActionVector.at(y).ArrivalTime > -1)
12966 SecondPassMessage(GiveMessages,
"Error in timetable - a repeat entry time exceeds 95h 59m, see service " + HC);
12972 if((
double)
TrainDataVector.at(x).ActionVector.at(y).DepartureTime > -1)
12977 SecondPassMessage(GiveMessages,
"Error in timetable - a repeat entry time exceeds 95h 59m, see service " + HC);
12990 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13016 (AVEntry.
Command ==
"Fns-sh") || (AVEntry.
Command ==
"F-nshs"));
13024 if(HeadCode.Length() > 4)
13026 HeadCode = HeadCode.SubString(HeadCode.Length() - 3, 4);
13037 int ForwardCount = 0;
13038 int ReverseCount = 0;
13040 if(MainHeadCode == SecondHeadCode)
13042 SecondPassMessage(GiveMessages,
"Error in timetable - Service " + MainHeadCode +
" has an event that references itself");
13051 if(TDEntry.
HeadCode == MainHeadCode)
13053 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13068 if(ForwardCount == 0)
13071 throw Exception(
"Error, ForwardCount == 0 in CheckForDuplicateCrossReferences after called with found values");
13073 if(ForwardCount > 2)
13076 SecondPassMessage(GiveMessages,
"Error in timetable - found more than two references to " + SecondHeadCode +
" from a train whose headcode is " +
13077 MainHeadCode +
". Check the service cross references from each service, and check whether one or other service is listed twice or more.");
13086 if(TDEntry.
HeadCode == SecondHeadCode)
13088 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13103 if(ReverseCount == 0)
13105 SecondPassMessage(GiveMessages,
"Error in timetable - cross reference missing in either " + MainHeadCode +
" or " + SecondHeadCode);
13110 if(ReverseCount > 2)
13113 SecondPassMessage(GiveMessages,
"Error in timetable - found more than two references to " + MainHeadCode +
" from a train whose headcode is " +
13114 SecondHeadCode +
". Check the service cross references from each service, and check whether one or other service is listed twice or more.");
13119 if(ForwardCount != ReverseCount)
13121 SecondPassMessage(GiveMessages,
"Error in timetable - " + MainHeadCode +
" has a different number of references to " + SecondHeadCode +
13122 " than the other way round");
13153 int ForwardCount = 0;
13154 int ReverseCount = 0;
13155 unsigned int ForwardTDVectorNumber, ReverseTDVectorNumber;
13164 if(TDEntry.
HeadCode == MainHeadCode)
13166 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13169 if(!Shuttle && (AVEntry.
Command !=
"Sns-sh") && (AVEntry.
Command !=
"Snt-sh") && (AVEntry.
Command !=
"Fns-sh") && (AVEntry.
Command !=
"Frh-sh"))
13174 ForwardEntryPtr = &AVEntry;
13176 ForwardTDVectorNumber = x;
13179 else if(Shuttle && ((AVEntry.
Command ==
"Sns-sh") || (AVEntry.
Command ==
"Snt-sh") || (AVEntry.
Command ==
"Fns-sh") ||
13180 (AVEntry.
Command ==
"Frh-sh")))
13185 ForwardEntryPtr = &AVEntry;
13187 ForwardTDVectorNumber = x;
13193 if(ForwardCount == 0)
13196 throw Exception(
"Error, ForwardCount == 0 in CheckCrossReferencesAndSetData after called with found values");
13198 if(ForwardCount > 1)
13200 SecondPassMessage(GiveMessages,
"Error in timetable - found more than one reference to " + OtherHeadCode +
" from a train whose headcode is " +
13210 if(TDEntry.
HeadCode == OtherHeadCode)
13212 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
13215 if(!Shuttle && (AVEntry.
Command !=
"Sns-sh") && (AVEntry.
Command !=
"Snt-sh") && (AVEntry.
Command !=
"Fns-sh") && (AVEntry.
Command !=
"Frh-sh"))
13221 ReverseEntryPtr = &AVEntry;
13222 ReverseTDVectorNumber = x;
13225 else if(Shuttle && ((AVEntry.
Command ==
"Sns-sh") || (AVEntry.
Command ==
"Snt-sh") || (AVEntry.
Command ==
"Fns-sh") || (AVEntry.
Command ==
"Frh-sh")))
13231 ReverseEntryPtr = &AVEntry;
13232 ReverseTDVectorNumber = x;
13239 if(ReverseCount == 0)
13241 SecondPassMessage(GiveMessages,
"Error in timetable - cross reference missing in either " + MainHeadCode +
" or " + OtherHeadCode);
13246 if(ReverseCount > 1)
13248 SecondPassMessage(GiveMessages,
"Error in timetable - found more than one reference to " + MainHeadCode +
" from a train whose headcode is " +
13255 bool ForwardShuttleStart = ((ForwardEntryPtr->Command ==
"Sns-sh") || (ForwardEntryPtr->Command ==
"Snt-sh"));
13256 bool ForwardShuttleFinish = ((ForwardEntryPtr->Command ==
"Fns-sh") || (ForwardEntryPtr->Command ==
"Frh-sh"));
13257 bool ReverseShuttleStart = ((ReverseEntryPtr->
Command ==
"Sns-sh") || (ReverseEntryPtr->
Command ==
"Snt-sh"));
13258 bool ReverseShuttleFinish = ((ReverseEntryPtr->
Command ==
"Fns-sh") || (ReverseEntryPtr->
Command ==
"Frh-sh"));
13262 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle train " + MainHeadCode +
" does not have a repeat");
13269 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle train " + OtherHeadCode +
" does not have a repeat");
13274 if(ForwardEntryPtr->LocationName ==
"")
13276 SecondPassMessage(GiveMessages,
"Error in timetable - location error in cross referenced trains " + MainHeadCode +
" and " + OtherHeadCode +
13277 ". One or other service does not have a location set");
13284 SecondPassMessage(GiveMessages,
"Error in timetable - location error in cross referenced trains " + MainHeadCode +
" and " + OtherHeadCode +
13285 ". One or other service does not have a location set");
13290 if(ForwardEntryPtr->LocationName != ReverseEntryPtr->
LocationName)
13292 SecondPassMessage(GiveMessages,
"Error in timetable - cross referenced train " + OtherHeadCode +
13293 " is at a different location to the referencing train " + MainHeadCode);
13301 if(ForwardEntryPtr->EventTime != ReverseEntryPtr->
EventTime)
13303 SecondPassMessage(GiveMessages,
"Error in timetable - cross referenced train " + OtherHeadCode +
13304 " has a different event time to the referencing train " + MainHeadCode);
13312 if(ForwardShuttleStart && ReverseShuttleFinish)
13317 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle service " + MainHeadCode +
13318 " first repeat restart time not consistent with finish service " + OtherHeadCode);
13324 if((ReverseEntryPtr->
Command ==
"Sfs") || (ReverseEntryPtr->
Command ==
"Sns"))
13327 if(ReverseTDVectorNumber == ForwardTDVectorNumber)
13329 SecondPassMessage(GiveMessages,
"Error in timetable - an 'Sfs' or 'Sns' event (" + OtherHeadCode +
13330 ") appears in the same sequence as the corresponding linked event " + MainHeadCode);
13336 if(ReverseEntryPtr->
Command ==
"Fjo")
13339 if(ReverseTDVectorNumber == ForwardTDVectorNumber)
13341 SecondPassMessage(GiveMessages,
"Error in timetable - an 'Fjo' event (" + OtherHeadCode +
13342 ") appears in the same sequence as the corresponding linked event " + MainHeadCode);
13348 if(ReverseEntryPtr->
Command ==
"Fns")
13351 if(ReverseTDVectorNumber == ForwardTDVectorNumber)
13353 SecondPassMessage(GiveMessages,
"Error in timetable - an 'Fns' event (" + OtherHeadCode +
13354 ") appears in the same sequence as the corresponding linked event " + MainHeadCode);
13360 if(ForwardEntryPtr->Command ==
"Sfs")
13362 if((ReverseEntryPtr->
Command !=
"fsp") && (ReverseEntryPtr->
Command !=
"rsp"))
13365 "Error in timetable - unable to find a corresponding split train event for the train that starts from a split whose headcode is " +
13372 if((ForwardEntryPtr->Command ==
"fsp") || (ForwardEntryPtr->Command ==
"rsp"))
13374 if(ReverseEntryPtr->
Command !=
"Sfs")
13376 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Sfs' event for the train split whose headcode is " +
13386 SecondPassMessage(GiveMessages,
"Error in timetable - can't find timetabled location '" + ForwardEntryPtr->LocationName +
"' in railway - perhaps there are concourses without platforms?");
13393 SecondPassMessage(GiveMessages,
"Error in timetable - can't find any named location elements at '" + ForwardEntryPtr->LocationName +
"' - perhaps there are concourses without platforms?");
13400 SecondPassMessage(GiveMessages,
"Error in timetable - location too short to split a train at " + ForwardEntryPtr->LocationName);
13405 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
13416 if(ForwardEntryPtr->Command ==
"Sns")
13418 if(ReverseEntryPtr->
Command !=
"Fns")
13420 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Fns' event for the 'Sns' train whose headcode is " +
13421 MainHeadCode +
" and is formed from a service with headcode " + OtherHeadCode);
13427 if(ForwardEntryPtr->Command ==
"Fns")
13429 if(ReverseEntryPtr->
Command !=
"Sns")
13431 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Sns' event for the train whose headcode is " + MainHeadCode +
13432 " and forms a new service with headcode " + OtherHeadCode);
13439 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
13450 if(ForwardEntryPtr->Command ==
"jbo")
13452 if(ReverseEntryPtr->
Command !=
"Fjo")
13454 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Fjo' event for the train whose headcode is " + MainHeadCode +
13455 " and is joined by a train with headcode " + OtherHeadCode);
13461 if(ForwardEntryPtr->Command ==
"Fjo")
13463 if(ReverseEntryPtr->
Command !=
"jbo")
13465 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'jbo' event for the train whose headcode is " + MainHeadCode +
13466 " and joins a train with headcode " + OtherHeadCode);
13473 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
13483 if(ForwardShuttleStart)
13486 if(!ReverseShuttleFinish)
13489 SecondPassMessage(GiveMessages,
"Error in timetable - incorrect shuttle link to train whose headcode is " + MainHeadCode +
13490 " from train whose headcode is " + OtherHeadCode +
", has to be Fns-sh, Frh-sh");
13496 if(ReverseShuttleStart)
13499 if(!ForwardShuttleFinish)
13502 SecondPassMessage(GiveMessages,
"Error in timetable - incorrect shuttle link to train whose headcode is " + OtherHeadCode +
13503 " from train whose headcode is " + MainHeadCode +
", has to be Fns-sh, Frh-sh");
13510 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
13522 bool MainRepeat =
false, OtherRepeat =
false;
13532 OtherRepeat =
true;
13535 if((MainRepeat && !OtherRepeat) || (!MainRepeat && OtherRepeat))
13537 SecondPassMessage(GiveMessages,
"Error in timetable - only one repeat is provided for the train whose headcode is " + MainHeadCode +
13538 " and the associated train with headcode " + OtherHeadCode);
13543 if(MainRepeat && OtherRepeat)
13549 SecondPassMessage(GiveMessages,
"Error in timetable - repeat items don't correspond for the train whose headcode is " + MainHeadCode +
13550 " and the associated train with headcode " + OtherHeadCode);
13572 while(Input[1] ==
' ')
13574 if(Input.Length() > 1)
13576 Input = Input.SubString(2, Input.Length() - 1);
13590 while(Input[Input.Length()] ==
' ')
13592 if(Input.Length() > 1)
13594 Input = Input.SubString(1, Input.Length() - 1);
13604 AnsiString Output =
"";
13605 bool DelimiterFound =
false;
13607 for(
int x = 1; x < Input.Length() + 1; x++)
13611 if(Input[x] ==
' ')
13616 if((Input[x] !=
',') && (Input[x] !=
';'))
13618 DelimiterFound =
false;
13619 Output = Output + Input[x];
13623 DelimiterFound =
true;
13624 Output = Output + Input[x];
13636 DelimiterFound =
false;
13637 for(
int x = Input.Length(); x > 0; x--)
13641 if(Input[x] ==
' ')
13646 if((Input[x] !=
',') && (Input[x] !=
';'))
13648 DelimiterFound =
false;
13649 Output = AnsiString(Input[x]) + Output;
13653 DelimiterFound =
true;
13654 Output = AnsiString(Input[x]) + Output;
13674 if((AVEntry0.
Command !=
"Snt") && (AVEntry0.
Command !=
"Snt-sh"))
13676 throw Exception(
"Error, first entry not 'Snt' or 'Snt-sh' in IsSNTEntryLocated");
13688 LocationName = LocRear;
13692 LocationName = LocFront;
13694 if(LocationName ==
"")
13720 AnsiString TimeLocLocationName;
13721 bool FoundFlag =
false;
13723 for(
unsigned int y = 0; y < TDEntry.
ActionVector.size(); y++)
13738 if(TimeLocLocationName == LocationName)
13755 int RearPosition = 0, FrontPosition = 0, RearExitPos = 0;
13758 if(RearPosition < 0)
13765 if(FrontPosition < 0)
13776 for(
int x = 0; x < 4; x++)
13778 if(RearTrackElement.
Conn[x] == FrontPosition)
13793 TimetableMessage(GiveMessages,
"Front of train attempting to start on a continuation at: " + FrontElementStr);
13800 TimetableMessage(GiveMessages,
"Train attempting to start on a level crossing at: " + FrontElementStr);
13806 TimetableMessage(GiveMessages,
"Train attempting to start on a level crossing at: " + RearElementStr);
13811 if((RearType ==
Points) && (RearExitPos == 3))
13813 TimetableMessage(GiveMessages,
"Front of train attempting to start on element connected to diverging points at: " + RearElementStr);
13819 TimetableMessage(GiveMessages,
"Rear of train attempting to start on element connected to diverging points at: " + FrontElementStr);
13834 AnsiString(RearExitPos));
13845 int FrontPosition = RearTrackElement.
Conn[RearExitPos];
13847 int FrontEntryPos = RearTrackElement.
ConnLinkPos[RearExitPos];
13850 AnsiString RearName, FrontName;
13866 FrontName = FrontTrackElement.
ElementID;
13869 int LockedVectorNumber;
14020 "," + AnsiString(IncDigits));
14023 throw Exception(
"Error, last 2 characters not both digits and IncDigits > 0 in GetRepeatHeadCode");
14028 return(BaseHeadCode);
14030 int BaseDigits = BaseHeadCode.SubString(3, 2).ToInt();
14031 int NextRepeatDigits = BaseDigits + (IncDigits * RepeatNumber);
14033 while(NextRepeatDigits >= 100)
14035 NextRepeatDigits -= 100;
14037 AnsiString NextRepeatDigitsStr = AnsiString(NextRepeatDigits);
14039 if(NextRepeatDigitsStr.Length() < 2)
14041 NextRepeatDigitsStr = AnsiString(
'0') + NextRepeatDigitsStr;
14043 AnsiString NextRepeatHeadCode = BaseHeadCode.SubString(1, 2) + NextRepeatDigitsStr;
14046 return(NextRepeatHeadCode);
14054 AnsiString(RepeatNumber) +
"," + AnsiString(IncMinutes));
14055 TDateTime NextRepeatTime = BasicTime + TDateTime(((
double)(RepeatNumber * IncMinutes)) / 1440.0);
14058 return(NextRepeatTime);
14067 AnsiString(
double(ReverseEventTime)) +
"," + AnsiString(RepeatMinutes));
14068 int ForwardSecs = int(
double(ForwardEventTime) * 86400);
14069 int ReverseSecs = int(
double(ReverseEventTime) * 86400);
14070 int RepeatSecs = RepeatMinutes * 60;
14072 if((ForwardSecs > (ReverseSecs - RepeatSecs + 10)) || (ForwardSecs < (ReverseSecs - RepeatSecs - 10)))
14090 NonRepeatingHeadCode);
14091 int ForwardCount = 0;
14092 int ReverseCount = 0;
14093 unsigned int ForwardTDVectorNumber, ReverseTDVectorNumber;
14103 if(TDEntry.
HeadCode == MainHeadCode)
14105 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
14111 ForwardEntryPtr = &AVEntry;
14113 ForwardTDVectorNumber = x;
14118 if(ForwardCount == 0)
14121 throw Exception(
"Error, ForwardCount == 0 in CheckNonRepeatingShuttleLinksAndSetData after called with found values");
14123 if(ForwardCount > 1)
14125 SecondPassMessage(GiveMessages,
"Error in timetable - found more than one reference to " + NonRepeatingHeadCode +
" from a train whose headcode is " +
14135 if(TDEntry.
HeadCode == NonRepeatingHeadCode)
14137 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
14144 ReverseEntryPtr = &AVEntry;
14145 ReverseTDVectorNumber = x;
14151 if(ReverseCount == 0)
14153 SecondPassMessage(GiveMessages,
"Error in timetable - cross reference missing in either " + MainHeadCode +
" or " + NonRepeatingHeadCode);
14158 if(ReverseCount > 1)
14160 SecondPassMessage(GiveMessages,
"Error in timetable - found more than one reference to " + MainHeadCode +
" from a train whose headcode is " +
14161 NonRepeatingHeadCode);
14166 if(((ForwardEntryPtr->Command ==
"F-nshs") || (ForwardEntryPtr->Command ==
"Sns-fsh")) && (MainTrainDataPtr->
ActionVector.back().FormatType ==
Repeat))
14168 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle connecting train " + MainHeadCode +
" shouldn't have a repeat");
14173 if((ForwardEntryPtr->Command !=
"F-nshs") && (ForwardEntryPtr->Command !=
"Sns-fsh") && (MainTrainDataPtr->
ActionVector.back().FormatType !=
Repeat))
14175 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle train " + MainHeadCode +
" does not have a repeat item");
14180 if(ForwardEntryPtr->LocationName ==
"")
14182 SecondPassMessage(GiveMessages,
"Error in timetable - location error in cross referenced trains " + MainHeadCode +
" and " + NonRepeatingHeadCode +
14183 ". One or other service does not have a location set");
14190 SecondPassMessage(GiveMessages,
"Error in timetable - location error in cross referenced trains " + MainHeadCode +
" and " + NonRepeatingHeadCode +
14191 ". One or other service does not have a location set");
14196 if(ForwardEntryPtr->LocationName != ReverseEntryPtr->
LocationName)
14198 SecondPassMessage(GiveMessages,
"Error in timetable - cross referenced train " + NonRepeatingHeadCode +
14199 " is at a different location to the referencing train " + MainHeadCode);
14204 if(ForwardEntryPtr->Command ==
"F-nshs")
14207 if(ForwardEntryPtr->EventTime != ReverseEntryPtr->
EventTime)
14209 SecondPassMessage(GiveMessages,
"Error in timetable - shuttle in-link service " + MainHeadCode +
14210 " finish time not consistent with start time of shuttle service " + NonRepeatingHeadCode);
14216 if(ForwardEntryPtr->Command ==
"Fns-sh")
14220 MainTrainDataPtr->
ActionVector.back().RearStartOrRepeatMins, MainTrainDataPtr->
ActionVector.back().NumberOfRepeats))
14222 SecondPassMessage(GiveMessages,
"Error in timetable - service " + NonRepeatingHeadCode +
", which links out from shuttle service " + MainHeadCode +
14223 ", has the wrong start time. It should correspond to the finish time of the last shuttle.");
14229 if((ForwardEntryPtr->Command ==
"F-nshs") || (ForwardEntryPtr->Command ==
"Sns-fsh"))
14232 if(ReverseTDVectorNumber == ForwardTDVectorNumber)
14234 SecondPassMessage(GiveMessages,
"Error in timetable - the non repeating link service " + NonRepeatingHeadCode +
14235 " appears in the same sequence as the corresponding shuttle service " + MainHeadCode);
14253 if(ForwardEntryPtr->Command ==
"Sns-sh")
14255 if(ReverseEntryPtr->
Command !=
"F-nshs")
14257 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'F-nshs' event for the 'Sns-sh' train whose headcode is " +
14258 MainHeadCode +
" and is a new shuttle service formed from the service with headcode " + NonRepeatingHeadCode);
14264 if(ForwardEntryPtr->Command ==
"F-nshs")
14266 if(ReverseEntryPtr->
Command !=
"Sns-sh")
14268 SecondPassMessage(GiveMessages,
"Error in timetable - unable to find a corresponding 'Sns-sh' event for the 'F-nshs' train whose headcode is " +
14269 MainHeadCode +
" and forms a new shuttle service with headcode " + NonRepeatingHeadCode);
14276 ForwardEntryPtr->LinkedTrainEntryPtr = OtherTrainDataPtr;
14287 if(ForwardEntryPtr->Command ==
"Sns-fsh")
14289 if(ReverseEntryPtr->
Command !=
"Fns-sh")
14292 "Error in timetable - unable to find a corresponding 'Fns-sh' event for the 'Sns-fsh' non-shuttle service whose headcode is " + MainHeadCode +
14293 " formed from a shuttle service with headcode " + NonRepeatingHeadCode);
14299 if(ForwardEntryPtr->Command ==
"Fns-sh")
14301 if(ReverseEntryPtr->
Command !=
"Sns-fsh")
14304 "Error in timetable - unable to find a corresponding 'Sns-fsh' event for the 'Fns-sh' shuttle service whose headcode is " + MainHeadCode +
14305 " and forms a new non-shuttle service with headcode " + NonRepeatingHeadCode);
14312 ForwardEntryPtr->NonRepeatingShuttleLinkEntryPtr = OtherTrainDataPtr;
14336 +
"," + AnsiString(
double(ReverseEventTime)) +
"," + AnsiString(RepeatMinutes) +
"," + AnsiString(RepeatNumber));
14337 int ForwardSecs = int(
double(ForwardEventTime) * 86400);
14338 int ReverseSecs = int(
double(ReverseEventTime) * 86400);
14339 int RepeatSecs = RepeatMinutes * RepeatNumber * 60;
14341 if((ReverseSecs > (ForwardSecs + RepeatSecs + 10)) || (ReverseSecs < (ForwardSecs + RepeatSecs - 10)))
14365 throw Exception(
"Error - last entry in " + TDEntryPtr->
HeadCode +
" service is not a repeat - should have already found this error");
14368 AnsiString OriginalHeadCode = TDEntryPtr->
HeadCode;
14369 AnsiString LastActionCommand = (TDEntryPtr->
ActionVector.end() - 2)->Command;
14371 if((LastActionCommand !=
"Fns") && (LastActionCommand !=
"Fns-sh") && (LastActionCommand !=
"Frh-sh"))
14373 SecondPassMessage(GiveMessages,
"Error in timetable - last event in shuttle service " + TDEntryPtr->
HeadCode +
" is not 'Fns', 'Fns-sh' or 'Frh-sh'");
14378 while(LastActionCommand ==
"Fns")
14380 TDEntryPtr = (TDEntryPtr->
ActionVector.end() - 2)->LinkedTrainEntryPtr;
14381 LastActionCommand = (TDEntryPtr->
ActionVector.end() - 2)->Command;
14382 if((LastActionCommand !=
"Fns") && (LastActionCommand !=
"Fns-sh") && (LastActionCommand !=
"Frh-sh"))
14385 "Error in timetable - last event in a continuation shuttle service (i.e links back to a shuttle) whose headcode is " + TDEntryPtr->
HeadCode +
14386 " is not 'Fns', 'Fns-sh' or 'Frh-sh'");
14393 if((TDEntryPtr->
ActionVector.end() - 2)->LinkedTrainEntryPtr != ShuttleStartAddress)
14396 " is a shuttle finish, but it doesn't link back to the start of the original shuttle starting service " + OriginalHeadCode +
14397 ". The linking of two or more shuttles is not permitted.");
14417 ShowMessage(Message);
14435 ShowMessage(Message);
14473 AnsiString(ActionEventType) +
"," + LocationID);
14474 AnsiString BaseLog =
"", Prefix =
"", ErrorLog =
"", WarningStr =
"";
14476 Prefix =
" ERROR: ";
14479 Prefix =
" HELD: ";
14480 ErrorLog =
" can't enter railway, train obstructing entry position ";
14481 WarningStr =
" can't enter railway, train obstructing entry position ";
14486 Prefix =
" HELD: ";
14487 ErrorLog =
" can't be created, train obstructing ";
14488 WarningStr =
" can't be created, train obstructing ";
14493 Prefix =
" HELD: ";
14494 ErrorLog =
" can't be created on a locked route at ";
14495 WarningStr =
" can't be created on a locked route at ";
14500 Prefix =
" HELD: ";
14501 ErrorLog =
" can't enter on a locked route at ";
14502 WarningStr =
" can't enter on a locked route at ";
14507 Prefix =
" HELD: ";
14508 ErrorLog =
" can't be created, diverging points at ";
14509 WarningStr =
" can't be created, diverging points at ";
14514 ErrorLog =
" left railway unexpectedly at ";
14519 ErrorLog =
" left railway at an incorrect exit at ";
14524 ErrorLog =
" failed to split - location too short at ";
14525 WarningStr =
" failed to split, location too short at ";
14530 Prefix =
" HELD: ";
14531 ErrorLog =
" unable to split - other train obstructing at ";
14532 WarningStr =
" unable to split - other train obstructing at ";
14537 ErrorLog =
" stopped at buffers unexpectedly at position ";
14541 ErrorLog =
" failed to stop at ";
14546 ErrorLog =
" failed to split at ";
14551 ErrorLog =
" failed to be joined by other train at ";
14556 ErrorLog =
" failed to join other train at ";
14561 ErrorLog =
" failed to terminate at ";
14566 ErrorLog =
" failed to form new service at ";
14571 ErrorLog =
" failed to exit railway ";
14576 ErrorLog =
" failed to change direction at ";
14581 ErrorLog =
" failed to pass ";
14586 ErrorLog =
" facing buffers and unable to start at ";
14590 ErrorLog =
" DERAILED at position ";
14591 Prefix =
" DERAILMENT: ";
14596 ErrorLog =
" CRASHED INTO BUFFERS at ";
14597 Prefix =
" CRASH: ";
14602 ErrorLog =
" CRASHED INTO ROAD TRAFFIC AT A LEVEL CROSSING at ";
14603 Prefix =
" CRASH: ";
14608 ErrorLog =
" CRASHED INTO " + OtherHeadCode +
" at position ";
14609 Prefix =
" CRASH: ";
14613 else if(ActionEventType ==
FailSPAD)
14615 ErrorLog =
" PASSED SIGNAL AT DANGER at position ";
14616 Prefix =
" SPAD: ";
14621 ErrorLog =
"Signals reset ahead of train, route cancelled at position ";
14622 Prefix =
" SPAD RISK: ";
14627 ErrorLog =
" forced a route cancellation by occupying it incorrectly at ";
14631 Prefix =
" WARNING: ";
14632 ErrorLog =
" waiting to join " + OtherHeadCode +
" at ";
14633 WarningStr =
" waiting to join " + OtherHeadCode +
" at ";
14638 Prefix =
" WARNING: ";
14639 ErrorLog =
" waiting to be joined by " + OtherHeadCode +
" at ";
14640 WarningStr =
" waiting to be joined by " + OtherHeadCode +
" at ";
14679 std::ofstream OutFile(
"TrainData.csv");
14683 ShowMessage(
"Output file TrainData.csv failed to open");
14690 OutFile <<
"HeadCode" <<
',' <<
"Description" <<
',' <<
"StartSpeed" <<
',' <<
"MaxRunningSpeed" <<
',' <<
"NumberOfTrains" <<
'\n' <<
'\n';
14695 OutFile <<
',' <<
"FormatType" <<
',' <<
"EventTime" <<
',' <<
"ArrivalTime" <<
',' <<
"DepartureTime" <<
',' <<
"LocationName" <<
',' <<
"Command" <<
14696 ',' <<
"OtherHeadCode" <<
',' <<
"LinkedTrainEntryPtr" <<
',' <<
"RearStartOrRepeatMins" <<
',' <<
"FrontStartOrRepeatDigits" <<
',' <<
14697 "RepeatNumber" <<
'\n' <<
'\n';
14698 for(
unsigned int y = 0; y <
TrainDataVector.at(x).ActionVector.size(); y++)
14701 AnsiString TimetableEntryTypeStr;
14707 TimetableEntryTypeStr =
"NoFormat";
14713 TimetableEntryTypeStr =
"TimeLoc";
14719 TimetableEntryTypeStr =
"TimeTimeLoc";
14725 TimetableEntryTypeStr =
"TimeCmd";
14731 TimetableEntryTypeStr =
"StartNew";
14737 TimetableEntryTypeStr =
"TimeCmdHeadCode";
14743 TimetableEntryTypeStr =
"FinRemHere";
14749 TimetableEntryTypeStr =
"FNSShuttle";
14755 TimetableEntryTypeStr =
"SNTShuttle";
14761 TimetableEntryTypeStr =
"SNSShuttle";
14767 TimetableEntryTypeStr =
"SNSNonRepeatFromShuttle";
14773 TimetableEntryTypeStr =
"FSHNewService";
14779 TimetableEntryTypeStr =
"Repeat";
14785 TimetableEntryTypeStr =
"Default";
14796 OutFile <<
',' <<
',' <<
"Mass" <<
',' <<
"MaxBrakeRate" <<
',' <<
"PowerAtRail" <<
',' <<
"TrainID" <<
',' <<
"RunningEntry" <<
'\n' <<
'\n';
14797 for(
unsigned int y = 0; y <
TrainDataVector.at(x).TrainOperatingDataVector.size(); y++)
14800 AnsiString RunningEntryStr;
14806 RunningEntryStr =
"NotStarted";
14812 RunningEntryStr =
"Running";
14818 RunningEntryStr =
"Exited";
14822 OutFile <<
',' <<
',' << TOD.
TrainID <<
',' << RunningEntryStr.c_str() <<
',' <<
'\n';
14839 ShowMessage(Message);
14840 BaseTime = TDateTime::CurrentDateTime();
14854 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
14867 TTrain *NewTrain =
new TTrain(1, 0, 0,
"", 0, 1, 0, 0, 0, (
TTrainMode)0, 0, 0, 0, 0, 0);
14869 for(
int x = 0; x < NumberOfTrains; x++)
14871 *NewTrain =
TTrain(2, 0, 0,
"", 0, 1, 0, 0, 0, (
TTrainMode)0, 0, 0, 0, 0, 0);
14891 int NumberOfTrains;
14898 for(
int x = 0; x < NumberOfTrains; x++)
14935 for(
int x = 0; x < LockedRouteVectorSize; x++)
14942 LockedRouteObject.
LockStartTime = TDateTime(LockStartTimeDouble);
14953 int LockedRouteVectorSize;
14960 for(
int x = 0; x < LockedRouteVectorSize; x++)
15018 for(
int x = 0; x < ContinuationAutoSigVectorSize; x++)
15026 ContinuationAutoSigObject.
PassoutTime = TDateTime(PassoutTimeDouble);
15037 int ContinuationAutoSigVectorSize;
15044 for(
int x = 0; x < ContinuationAutoSigVectorSize; x++)
15114 if(AVFirstEntry.
Command ==
"Snt")
15138 CTEMMP.second = CTEEntry;
15145 throw Exception(
"Error, Last ActionVectorEntry not a repeat in BuildContinuationTrainExpectationMultiMap");
15153 CTEMMP.second = CTEEntry;
15174 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
15191 if((VecPos < 0) || (VecPos >= (
int)
TrainVector.size()))
15193 throw Exception(
"Out of Range Error, vector size: " + AnsiString(
TrainVector.size()) +
", VecPos: " + AnsiString(VecPos) +
" in TrainVectorAt");
15204 AnsiString RetStr =
"", PartStr =
"";
15319 AnsiString TTFileName = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
15323 TTFileName = CurDir +
"\\Formatted timetables\\Timetable " + TTFileName +
"; " + RailwayTitle +
"; " + TimetableTitle +
".csv";
15325 AnsiString ShortTTName =
"";
15327 for(
int x = TTFileName.Length(); x > 0; x--)
15329 if(TTFileName[x] ==
'\\')
15331 ShortTTName = TTFileName.SubString(x + 1, TTFileName.Length() - x - 4);
15336 ShowMessage(
"Creates two timetables named " + ShortTTName +
15337 " in the 'Formatted timetables' folder, one in service order in '.csv' format, and one in chronological order in '.txt' format");
15339 Screen->Cursor = TCursor(-11);
15341 AnsiString FormatNoDPStr =
"#######0";
15342 AnsiString TableTitle =
"", TimetableTimeStr =
"", MassStr =
"", PowerStr =
"", BrakeStr =
"", MaxSpeedStr =
"", FirstHeadCode =
"", Header =
"";
15345 TableTitle =
"Railway: " + RailwayTitle +
"; Timetable: " + TimetableTitle +
"; Start time: " + TimetableTimeStr;
15352 MassStr =
"", PowerStr =
"", BrakeStr =
"", MaxSpeedStr =
"";
15354 if(TrainDataEntry.
Mass > 0)
15356 MassStr =
"; Mass " + AnsiString::FormatFloat(FormatNoDPStr, ((
double)TrainDataEntry.
Mass) / 1000) +
"Te; ";
15360 PowerStr =
"Power " + AnsiString::FormatFloat(FormatNoDPStr, TrainDataEntry.
PowerAtRail / 1000 / 0.8) +
"kW; ";
15364 BrakeStr =
"Brake force " + AnsiString::FormatFloat(FormatNoDPStr, (TrainDataEntry.
MaxBrakeRate * TrainDataEntry.
Mass / 9810)) +
"Te; ";
15368 MaxSpeedStr =
"Maximum speed " + AnsiString::FormatFloat(FormatNoDPStr, TrainDataEntry.
MaxRunningSpeed) +
" km/h";
15370 FirstHeadCode = TrainDataEntry.
HeadCode;
15371 int IncDigits = 0, IncMinutes = 0;
15373 if(!ActionVector.empty())
15375 if(ActionVector.at(ActionVector.size() - 1).FormatType ==
Repeat)
15377 IncDigits = ActionVector.at(ActionVector.size() - 1).FrontStartOrRepeatDigits;
15378 IncMinutes = ActionVector.at(ActionVector.size() - 1).RearStartOrRepeatMins;
15386 if((TrainDataEntry.
Description !=
"") && (MassStr !=
""))
15388 OneTTLine.
Header = TrainDataEntry.
Description + MassStr + PowerStr + BrakeStr + MaxSpeedStr;
15396 for(
unsigned int z = 0; z < ActionVector.size(); z++)
15401 AnsiString PartStr =
"", TimeStr =
"";
15418 PartStr =
"Enters at " + ActionVectorEntry.
LocationName;
15422 PartStr =
"Created at " + ActionVectorEntry.
LocationName;
15432 PartStr =
"Enters at " + LocName;
15445 PartStr =
"Created at " + LocName;
15459 PartStr =
"Enters at " + ActionVectorEntry.
LocationName;
15464 PartStr =
"Repeat shuttle service at " + ActionVectorEntry.
LocationName +
" from ";
15470 else if(ActionVectorEntry.
Command ==
"Sfs")
15472 PartStr =
"New service at " + ActionVectorEntry.
LocationName +
" split from";
15476 else if(ActionVectorEntry.
Command ==
"Sns")
15478 PartStr =
"New service at " + ActionVectorEntry.
LocationName +
" from";
15486 PartStr =
"New service at " + ActionVectorEntry.
LocationName +
" from";
15492 PartStr =
"Repeat shuttle service at " + ActionVectorEntry.
LocationName +
" from ";
15500 PartStr =
"New service at " + ActionVectorEntry.
LocationName +
" from";
15503 AnsiString FirstHeadCode = TDE->
HeadCode;
15507 TimeStr =
GetRepeatHeadCode(36, FirstHeadCode, LastRepeatNumber, IncrementalDigits) +
" at " +
15519 PartStr =
"Arrives at " + ActionVectorEntry.
LocationName;
15521 OneTTEntry.
Action = PartStr;
15522 OneTTEntry.
Time = TimeStr;
15524 PartStr =
"Departs from " + ActionVectorEntry.
LocationName;
15529 PartStr =
"Arrives & departs " + ActionVectorEntry.
LocationName;
15535 PartStr =
"Arrives at " + ActionVectorEntry.
LocationName;
15540 PartStr =
"Departs from " + ActionVectorEntry.
LocationName;
15548 else if(ActionVectorEntry.
Command ==
"jbo")
15550 PartStr =
"Joined at " + ActionVectorEntry.
LocationName +
" by";
15554 else if(ActionVectorEntry.
Command ==
"fsp")
15556 PartStr =
"Splits from front at " + ActionVectorEntry.
LocationName +
" to form";
15560 else if(ActionVectorEntry.
Command ==
"rsp")
15562 PartStr =
"Splits from rear at " + ActionVectorEntry.
LocationName +
" to form";
15566 else if(ActionVectorEntry.
Command ==
"cdt")
15568 PartStr =
"Changes direction at " + ActionVectorEntry.
LocationName;
15574 if(ActionVectorEntry.
Command ==
"Fns")
15576 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service";
15580 else if(ActionVectorEntry.
Command ==
"F-nshs")
15582 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service";
15588 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service ";
15595 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service";
15601 PartStr =
"At " + ActionVectorEntry.
LocationName +
" forms new service";
15608 PartStr =
"Terminates shuttle service at " + ActionVectorEntry.
LocationName;
15613 else if(ActionVectorEntry.
Command ==
"Frh")
15615 PartStr =
"Terminates at " + ActionVectorEntry.
LocationName;
15620 if(ActionVector.at(z - 1).EventTime != TDateTime(-1))
15624 else if(ActionVector.at(z - 1).ArrivalTime != TDateTime(-1))
15634 else if(ActionVectorEntry.
Command ==
"Fer")
15636 AnsiString AllowedExits;
15640 else if(ActionVectorEntry.
Command ==
"Fjo")
15642 PartStr =
"At " + ActionVectorEntry.
LocationName +
" joins";
15651 OneTTEntry.
Action = PartStr;
15652 OneTTEntry.
Time = TimeStr;
15659 AllTTTrains->push_back(OneTTLine);
15663 std::ofstream TTFile(TTFileName.c_str());
15667 StopTTClockMessage(64,
"Formatted timetable file failed to open - can't be created");
15668 delete AllTTTrains;
15703 TTFile << TableTitle.c_str() <<
'\n' <<
'\n';
15704 for(
unsigned int x = 0; x < AllTTTrains->size(); x++)
15706 TTFile << AllTTTrains->at(x).Header.c_str();
15709 for(
int y = 0; y < AllTTTrains->at(x).NumberOfTrains; y++)
15711 if(y < (AllTTTrains->at(x).NumberOfTrains - 1))
15713 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).HeadCode.c_str() <<
',';
15717 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).HeadCode.c_str();
15720 TTFile <<
'\n' <<
'\n';
15722 for(
unsigned int z = 0; z < AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(0).OneFormattedTrainVector.size(); z++)
15724 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(0).OneFormattedTrainVector.at(z).Action.c_str() <<
',';
15725 for(
int y = 0; y < AllTTTrains->at(x).NumberOfTrains; y++)
15727 if(y < (AllTTTrains->at(x).NumberOfTrains - 1))
15729 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.at(z).Time.c_str() <<
',';
15733 TTFile << AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.at(z).Time.c_str();
15738 TTFile <<
'\n' <<
'\n';
15743 AnsiString TTFileName2 = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
15745 TTFileName2 = CurDir +
"\\Formatted timetables\\Timetable " + TTFileName2 +
"; " + RailwayTitle +
"; " + TimetableTitle +
".txt";
15747 std::ofstream TTFile2(TTFileName2.c_str());
15751 StopTTClockMessage(67,
"Chronological timetable file failed to open - can't be created");
15752 delete AllTTTrains;
15756 typedef std::multimap<AnsiString, AnsiString>TAnsiMultiMap;
15757 std::multimap<AnsiString, AnsiString>::iterator AMMIT;
15758 std::pair<AnsiString, AnsiString>AnsiMultiMapEntry;
15760 TAnsiMultiMap *TAMM =
new TAnsiMultiMap;
15765 TTFile2 << TableTitle.c_str() <<
'\n' <<
'\n';
15766 for(
unsigned int x = 0; x < AllTTTrains->size(); x++)
15768 for(
int y = 0; y < AllTTTrains->at(x).NumberOfTrains; y++)
15770 for(
unsigned int z = 0; z < AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.size(); z++)
15772 bool GiveMessagesFalse =
false;
15773 AnsiString TimeString = AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.at(z).Time;
15774 AnsiString HeadCodeString = AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).HeadCode;
15775 AnsiString ActionString = AllTTTrains->at(x).OneCompleteFormattedTrainVector.at(y).OneFormattedTrainVector.at(z).Action;
15780 AnsiString OtherHeadCode = TimeString.SubString(1, 4);
15781 TimeString = TimeString.SubString(9, 5);
15782 ActionString +=
" " + OtherHeadCode;
15784 if(TimeString.SubString(1, 7) ==
"End at ")
15787 TimeString = TimeString.SubString(8, 5);
15789 AnsiString OneLine = TimeString +
' ' + HeadCodeString +
' ' + ActionString +
'\n';
15790 AnsiMultiMapEntry.first = TimeString;
15791 AnsiMultiMapEntry.second = OneLine;
15792 TAMM->insert(AnsiMultiMapEntry);
15797 for(AMMIT = TAMM->begin(); AMMIT != TAMM->end(); AMMIT++)
15799 TTFile2 << (AMMIT->second).c_str();
15801 delete AllTTTrains;
15810 bool AtLocChecked,
int ArrRange,
int DepRange)
15814 bool AnalysisError =
false;
15838 TTrainDataVector::iterator TDVIt, TDVCopyIt;
15840 int IteratorNumber = 0;
15841 AnsiString AnsiSuffix =
"";
15846 for(TDVCopyIt = TrainDataVectorCopy.begin() + IteratorNumber; TDVCopyIt != TrainDataVectorCopy.end(); TDVCopyIt++)
15848 if(TDVCopyIt->ServiceReference == TDVIt->ServiceReference)
15851 AnsiSuffix = AnsiString(Suffix);
15852 TDVCopyIt->ServiceReference = TDVIt->ServiceReference +
"/" + AnsiSuffix;
15859 std::pair<AnsiString, TServiceCallingLocsList> AllServiceCallingLocsEntry;
15860 for(
unsigned int x = 0; x < TrainDataVectorCopy.size(); x++)
15865 ServiceCallingLocsList.clear();
15866 if(ActionVector.empty())
15870 if(ActionVector.at(0).SignallerControl)
15874 for(
unsigned int z = 0; z < ActionVector.size(); z++)
15892 int HLoc = TE.
HLoc;
15893 int VLoc = TE.
VLoc;
15894 AnsiString HString;
15895 AnsiString VString;
15898 HString =
'N' + AnsiString(HLoc).SubString(2, AnsiString(HLoc).Length() - 1);
15902 HString = AnsiString(HLoc);
15906 VString =
'N' + AnsiString(VLoc).SubString(2, AnsiString(VLoc).Length() - 1);
15910 VString = AnsiString(VLoc);
15912 ServiceCallingLocsList.push_back(HString +
'-' + VString);
15935 else if(AVE.
Command ==
"cdt")
15937 if(ActionVector.at(z-1).SequenceType ==
Start)
15941 else if(ActionVector.at(z+1).SequenceType ==
Finish)
15948 ServiceCallingLocsList.push_back(
"%%%" + TimeString);
15957 ServiceCallingLocsList.push_back(LName);
15961 int HLoc = TE.
HLoc;
15962 int VLoc = TE.
VLoc;
15963 AnsiString HString;
15964 AnsiString VString;
15967 HString =
'N' + AnsiString(HLoc).SubString(2, AnsiString(HLoc).Length() - 1);
15971 HString = AnsiString(HLoc);
15975 VString =
'N' + AnsiString(VLoc).SubString(2, AnsiString(VLoc).Length() - 1);
15979 VString = AnsiString(VLoc);
15981 ServiceCallingLocsList.push_back(HString +
'-' + VString);
15985 AllServiceCallingLocsEntry.second = ServiceCallingLocsList;
16019 ShowMessage(
"Unable to create a program-readable timetable - please check the timetable file validity");
16025 bool NumPlatsAtThisLocCalculated =
false, ArrivalsPrinted =
false, DeparturesPrinted =
false, AtLocsPrinted =
false;
16026 AnsiString PreviousService =
"", PreviousServiceAndRepeatNumTotalOutput =
"", BasicTime =
"", MinuteString =
"", LastAnsiTime =
"";
16027 int NumTrains = 0, NumPlats = 0, LastFrhCount = 0, FrhCount = 0, NumTrainsAtLoc = 0;
16031 for(
unsigned int x = 0; x < TrainDataVectorCopy.size(); x++)
16036 TDateTime LastTDTime;
16037 int IncMinutes = 0;
16039 if(ActionVector.empty())
16043 if(ActionVector.at(0).SignallerControl)
16047 if(AVLast->FormatType ==
Repeat)
16049 IncMinutes = ActionVector.at(ActionVector.size() - 1).RearStartOrRepeatMins;
16057 if(AVLast->ArrivalTime != TDateTime(-1))
16059 LastTDTime = AVLast->ArrivalTime;
16061 else if(AVLast->EventTime != TDateTime(-1))
16063 LastTDTime = AVLast->EventTime;
16112 for(
unsigned int x = 0; x < TrainDataVectorCopy.size(); x++)
16117 int IncMinutes = 0;
16119 if(ActionVector.empty())
16123 if(ActionVector.at(0).SignallerControl)
16127 if(ActionVector.at(ActionVector.size() - 1).FormatType ==
Repeat)
16129 IncMinutes = ActionVector.at(ActionVector.size() - 1).RearStartOrRepeatMins;
16131 for(
int y = 0; y < NumTrains; y++)
16145 for(
unsigned int z = 0; z < ActionVector.size(); z++)
16160 LocServiceTimesVector.push_back(TLSTEntry);
16163 AnsiString IncTime =
"", FoundStopTime =
"";
16164 for(
unsigned int a = z + 1; a < ActionVector.size(); a++)
16166 if(ActionVector.at(a).FormatType ==
TimeLoc)
16171 if(ActionVector.at(a).SequenceType ==
Finish)
16177 if(FoundStopTime ==
"")
16179 throw Exception(
"Failure to determine FoundStopTime for located Snt");
16181 int WhileCount = 0;
16190 if(IncTime >= FoundStopTime)
16194 LocServiceTimesVector.push_back(TLSTEntry);
16195 if(WhileCount > 2000)
16197 throw Exception(
"While loop failed to break in 2000 loops for located Snt");
16210 int HLoc = TE.
HLoc;
16211 int VLoc = TE.
VLoc;
16212 AnsiString HString;
16213 AnsiString VString;
16216 HString =
'N' + AnsiString(HLoc).SubString(2, AnsiString(HLoc).Length() - 1);
16220 HString = AnsiString(HLoc);
16224 VString =
'N' + AnsiString(VLoc).SubString(2, AnsiString(VLoc).Length() - 1);
16228 VString = AnsiString(VLoc);
16230 TLSTEntry.
Location = HString +
'-' + VString;
16234 LocServiceTimesVector.push_back(TLSTEntry);
16242 LocServiceTimesVector.push_back(TLSTEntry);
16244 AnsiString IncTime =
"", FoundStopTime =
"";
16245 for(
unsigned int a = z + 1; a < ActionVector.size(); a++)
16247 if(ActionVector.at(a).FormatType ==
TimeLoc)
16252 if(ActionVector.at(a).SequenceType ==
Finish)
16258 if(FoundStopTime ==
"")
16260 throw Exception(
"Failure to determine FoundStopTime for SequenceType == Start");
16262 int WhileCount = 0;
16271 if(IncTime >= FoundStopTime)
16275 LocServiceTimesVector.push_back(TLSTEntry);
16276 if(WhileCount > 2000)
16278 throw Exception(
"While loop failed to break in 2000 loops for SequenceType == Start");
16288 bool SkipAddingMinutes =
false;
16291 LocServiceTimesVector.push_back(TLSTEntry);
16293 AnsiString IncTime =
"", FoundStopTime =
"";
16294 for(
unsigned int a = z + 1; a < ActionVector.size(); a++)
16296 if(ActionVector.at(a).FormatType ==
TimeLoc)
16301 if(ActionVector.at(a).SequenceType ==
Finish)
16304 if((a == z + 1) && (FoundStopTime == TLSTEntry.
ArrTime) && ((ActionVector.at(a).LinkedTrainEntryPtr > 0) || (ActionVector.at(a).NonRepeatingShuttleLinkEntryPtr > 0)))
16307 LocServiceTimesVector.pop_back();
16308 SkipAddingMinutes =
true;
16313 if(FoundStopTime ==
"")
16315 throw Exception(
"Failure to determine FoundStopTime for SequenceType == Start");
16317 if(!SkipAddingMinutes)
16319 int WhileCount = 0;
16328 if(IncTime >= FoundStopTime)
16332 LocServiceTimesVector.push_back(TLSTEntry);
16333 if(WhileCount > 2000)
16335 throw Exception(
"While loop failed to break in 2000 loops for SequenceType == Start");
16344 if((TLSTEntry.
Location == LocServiceTimesVector.back().Location) && (TLSTEntry.
ServiceAndRepeatNum == LocServiceTimesVector.back().ServiceAndRepeatNum))
16346 if(TLSTEntry.
DepTime == LocServiceTimesVector.back().ArrTime)
16348 TLSTEntry.
ArrTime = LocServiceTimesVector.back().ArrTime;
16349 LocServiceTimesVector.pop_back();
16350 LocServiceTimesVector.push_back(TLSTEntry);
16355 LocServiceTimesVector.push_back(TLSTEntry);
16361 LocServiceTimesVector.push_back(TLSTEntry);
16380 LocServiceTimesVector.push_back(TLSTEntry);
16384 AnsiString TempDepTime = TLSTEntry.
DepTime;
16386 LocServiceTimesVector.push_back(TLSTEntry);
16388 while(TLSTEntry.
AtLocTime < TempDepTime)
16393 TLSTEntry.
DepTime = TempDepTime;
16394 LocServiceTimesVector.push_back(TLSTEntry);
16398 LocServiceTimesVector.push_back(TLSTEntry);
16416 AnsiString HString;
16417 AnsiString VString;
16420 HString =
'N' + AnsiString(HLoc).SubString(2, AnsiString(HLoc).Length() - 1);
16424 HString = AnsiString(HLoc);
16428 VString =
'N' + AnsiString(VLoc).SubString(2, AnsiString(VLoc).Length() - 1);
16432 VString = AnsiString(VLoc);
16434 TLSTEntry.
Location = HString +
'-' + VString;
16436 LocServiceTimesVector.push_back(TLSTEntry);
16441 AnsiString FrhTime;
16442 if(ActionVector.at(z - 1).ArrivalTime != TDateTime(-1))
16446 else if(ActionVector.at(z - 1).EventTime != TDateTime(-1))
16454 LocServiceTimesVector.push_back(TLSTEntry);
16460 LocServiceTimesVector.push_back(TLSTEntry);
16465 else if(AVE.
Command ==
"Frh-sh")
16467 if(y == NumTrains - 1)
16473 LocServiceTimesVector.push_back(TLSTEntry);
16479 LocServiceTimesVector.push_back(TLSTEntry);
16498 TLocServiceTimesVector::iterator Ptr1, Ptr2;
16501 AnsiString TTFileName3 = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
16502 TTFileName3 = CurDir +
"\\Formatted timetables\\Conflict Analysis " + TTFileName3 +
"; " + RailwayTitle +
"; " + TimetableTitle +
".csv";
16504 std::ofstream TTFile3(TTFileName3.c_str());
16508 ShowMessage(
"Conflict Analysis file failed to open - can't be created");
16512 if(LocServiceTimesVector.empty())
16514 ShowMessage(
"No timetabled services found");
16516 DeleteFile(TTFileName3);
16520 TTFile3 <<
"Timetable analysis for timetable: '" + TimetableTitle +
"' in conjunction with railway: '" + RailwayTitle +
"'\n\n\n";
16527 Ptr1 = LocServiceTimesVector.begin();
16529 while(Ptr2 != LocServiceTimesVector.end())
16531 while(Ptr2->Location == Ptr1->Location)
16534 if(Ptr2 == LocServiceTimesVector.end())
16541 if(Ptr2 != LocServiceTimesVector.end())
16549 TTFile3 <<
"Arrival analysis: an asterisk means that the number of same approach code arrivals is equal to or greater than the number of platforms.\n";
16550 TTFile3 <<
"If the total number of arrivals exceeds the number of platforms the 'Trains present at location analysis' will show an asterisk.\n\n";
16551 MinuteString =
" minutes";
16552 AnsiString ServiceAndRepeatNumTotal =
"", ServiceAndRepeatNumTotalOutput =
"";
16555 MinuteString =
" minute";
16557 TTFile3 <<
"Location,Number of,Number of,Services arriving within " << AnsiString(ArrRange) << MinuteString <<
" with their arrival times and approach codes\n";
16558 TTFile3 <<
",Platforms,Trains\n\n";
16560 Ptr1 = LocServiceTimesVector.begin();
16562 while(Ptr2 != LocServiceTimesVector.end())
16564 PreviousService =
"";
16565 NumTrainsAtLoc = 0;
16566 ServiceAndRepeatNumTotal =
"";
16568 NumPlatsAtThisLocCalculated =
false;
16570 while((Ptr2->Location != Ptr1->Location) || ((Ptr1->Location ==
"") && (Ptr2->Location ==
"")))
16572 PreviousService =
"";
16573 NumTrainsAtLoc = 0;
16574 ServiceAndRepeatNumTotal =
"";
16576 NumPlatsAtThisLocCalculated =
false;
16580 if(Ptr2 == LocServiceTimesVector.end())
16585 if(Ptr2 == LocServiceTimesVector.end())
16589 while(Ptr2->Location == Ptr1->Location)
16591 PreviousService =
"";
16592 NumTrainsAtLoc = 0;
16593 ServiceAndRepeatNumTotal =
"";
16594 BasicTime = Ptr1->ArrTime;
16595 if((Ptr1->Location ==
"") && (Ptr2->Location ==
""))
16599 while(!
WithinTimeRange(0, BasicTime, Ptr2->ArrTime, ArrRange) || ((Ptr1->ArrTime ==
"") && (Ptr2->ArrTime ==
"")))
16601 BasicTime = Ptr2->ArrTime;
16604 if(Ptr2 == LocServiceTimesVector.end())
16608 if(Ptr2->Location != Ptr1->Location)
16613 if(Ptr2 == LocServiceTimesVector.end())
16617 if(Ptr2->Location != Ptr1->Location)
16623 if((Ptr1->ArrTime ==
"") && (Ptr2->ArrTime ==
""))
16627 if(!NumPlatsAtThisLocCalculated)
16630 NumPlatsAtThisLocCalculated =
true;
16632 if(Ptr1->ServiceAndRepeatNum != PreviousService)
16634 if(ServiceAndRepeatNumTotal ==
"")
16636 ServiceAndRepeatNumTotal = Ptr1->ServiceAndRepeatNum +
"," + Ptr1->ArrTime;
16637 NumTrainsAtLoc = 1;
16641 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr1->ServiceAndRepeatNum +
"," + Ptr1->ArrTime;
16644 PreviousService = Ptr2->ServiceAndRepeatNum;
16645 if(ServiceAndRepeatNumTotal ==
"")
16647 ServiceAndRepeatNumTotal = Ptr2->ServiceAndRepeatNum +
"," + Ptr2->ArrTime;
16648 NumTrainsAtLoc = 1;
16652 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr2->ServiceAndRepeatNum +
"," + Ptr2->ArrTime;
16656 if((Ptr2 == LocServiceTimesVector.end()) || (Ptr2->Location != Ptr1->Location) || (!
WithinTimeRange(2, BasicTime, Ptr2->ArrTime, ArrRange)))
16658 int MaxNumberOfSameDirections = 0;
16659 ServiceAndRepeatNumTotalOutput =
ConsolidateSARNTArrDep(1, ServiceAndRepeatNumTotal, NumTrainsAtLoc, Ptr1->Location,
true, AnalysisError, MaxNumberOfSameDirections);
16664 throw Exception(ServiceAndRepeatNumTotalOutput.c_str());
16668 AnsiString Asterisk =
"";
16669 if(MaxNumberOfSameDirections >= NumPlats)
16674 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << ServiceAndRepeatNumTotalOutput <<
'\n';
16675 ArrivalsPrinted =
true;
16676 ServiceAndRepeatNumTotal =
"";
16678 if(Ptr2 == LocServiceTimesVector.end())
16682 if(Ptr2->Location != Ptr1->Location)
16687 if(Ptr2 == LocServiceTimesVector.end())
16693 if(!ArrivalsPrinted)
16695 TTFile3 <<
"Nothing to report for arrivals";
16697 TTFile3 <<
"\n\n\n";
16705 Ptr1 = LocServiceTimesVector.begin();
16707 while(Ptr2 != LocServiceTimesVector.end())
16709 while(Ptr2->Location == Ptr1->Location)
16712 if(Ptr2 == LocServiceTimesVector.end())
16719 if(Ptr2 != LocServiceTimesVector.end())
16726 TTFile3 <<
"Departure analysis: an asterisk means that the number of same exit code departures is equal to or greater than the number of platforms.\n";
16727 TTFile3 <<
"If the total number of departures exceeds the number of platforms the 'Trains present at location analysis' will show an asterisk.\n\n";
16728 MinuteString =
" minutes";
16729 AnsiString ServiceAndRepeatNumTotal =
"", ServiceAndRepeatNumTotalOutput =
"";
16732 MinuteString =
" minute";
16734 TTFile3 <<
"Location,Number of,Number of,Services departing within " << AnsiString(DepRange) << MinuteString <<
" with their departure times and exit codes\n";
16735 TTFile3 <<
",Platforms,Trains\n\n";
16737 Ptr1 = LocServiceTimesVector.begin();
16739 while(Ptr2 != LocServiceTimesVector.end())
16741 PreviousService =
"";
16742 NumTrainsAtLoc = 0;
16743 ServiceAndRepeatNumTotal =
"";
16745 NumPlatsAtThisLocCalculated =
false;
16747 while((Ptr2->Location != Ptr1->Location) || ((Ptr1->Location ==
"") && (Ptr2->Location ==
"")))
16749 PreviousService =
"";
16750 NumTrainsAtLoc = 0;
16751 ServiceAndRepeatNumTotal =
"";
16753 NumPlatsAtThisLocCalculated =
false;
16757 if(Ptr2 == LocServiceTimesVector.end())
16762 if(Ptr2 == LocServiceTimesVector.end())
16766 while(Ptr2->Location == Ptr1->Location)
16768 PreviousService =
"";
16769 NumTrainsAtLoc = 0;
16770 ServiceAndRepeatNumTotal =
"";
16771 BasicTime = Ptr1->DepTime;
16772 if((Ptr1->Location ==
"") && (Ptr2->Location ==
""))
16776 while(!
WithinTimeRange(3, BasicTime, Ptr2->DepTime, DepRange) || ((Ptr1->DepTime ==
"") && (Ptr2->DepTime ==
"")))
16778 BasicTime = Ptr2->DepTime;
16781 if(Ptr2 == LocServiceTimesVector.end())
16785 if(Ptr2->Location != Ptr1->Location)
16790 if(Ptr2 == LocServiceTimesVector.end())
16794 if(Ptr2->Location != Ptr1->Location)
16800 if((Ptr1->DepTime ==
"") && (Ptr2->DepTime ==
""))
16804 if(!NumPlatsAtThisLocCalculated)
16807 NumPlatsAtThisLocCalculated =
true;
16809 if(Ptr1->ServiceAndRepeatNum != PreviousService)
16811 if(ServiceAndRepeatNumTotal ==
"")
16813 ServiceAndRepeatNumTotal = Ptr1->ServiceAndRepeatNum +
"," + Ptr1->DepTime;
16814 NumTrainsAtLoc = 1;
16818 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr1->ServiceAndRepeatNum +
"," + Ptr1->DepTime;
16821 PreviousService = Ptr2->ServiceAndRepeatNum;
16822 if(ServiceAndRepeatNumTotal ==
"")
16824 ServiceAndRepeatNumTotal = Ptr2->ServiceAndRepeatNum +
"," + Ptr2->DepTime;
16825 NumTrainsAtLoc = 1;
16829 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr2->ServiceAndRepeatNum +
"," + Ptr2->DepTime;
16833 if((Ptr2 == LocServiceTimesVector.end()) || (Ptr2->Location != Ptr1->Location) || (!
WithinTimeRange(5, BasicTime, Ptr2->DepTime, DepRange)))
16835 int MaxNumberOfSameDirections = 0;
16836 ServiceAndRepeatNumTotalOutput =
ConsolidateSARNTArrDep(3, ServiceAndRepeatNumTotal, NumTrainsAtLoc, Ptr1->Location,
false, AnalysisError, MaxNumberOfSameDirections);
16841 throw Exception(ServiceAndRepeatNumTotalOutput.c_str());
16845 AnsiString Asterisk =
"";
16846 if(MaxNumberOfSameDirections >= NumPlats)
16851 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << ServiceAndRepeatNumTotalOutput <<
'\n';
16852 DeparturesPrinted =
true;
16853 ServiceAndRepeatNumTotal =
"";
16855 if(Ptr2 == LocServiceTimesVector.end())
16859 if(Ptr2->Location != Ptr1->Location)
16864 if(Ptr2 == LocServiceTimesVector.end())
16870 if(!DeparturesPrinted)
16872 TTFile3 <<
"Nothing to report for departures";
16874 TTFile3 <<
"\n\n\n";
16884 Ptr1 = LocServiceTimesVector.begin();
16886 while(Ptr2 != LocServiceTimesVector.end())
16888 while(Ptr2->Location == Ptr1->Location)
16891 if(Ptr2 == LocServiceTimesVector.end())
16898 if(Ptr2 != LocServiceTimesVector.end())
16905 TTFile3 <<
"Trains present at location analysis: an asterisk means that the number of trains at the location is greater than the number of platforms.\n\n";
16906 TTFile3 <<
"Location,Number of,Number of,Time,Services at the location at that time\n";
16907 TTFile3 <<
",Platforms,Trains,\n\n";
16908 AnsiString ServiceAndRepeatNumTotal =
"", ServiceAndRepeatNumTotalOutput =
"";
16909 Ptr1 = LocServiceTimesVector.begin();
16911 while(Ptr2 != LocServiceTimesVector.end())
16913 PreviousService =
"";
16914 ServiceAndRepeatNumTotal =
"";
16915 NumTrainsAtLoc = 0;
16917 NumPlatsAtThisLocCalculated =
false;
16919 while((Ptr2->Location != Ptr1->Location) || ((Ptr1->Location ==
"") && (Ptr2->Location ==
"")))
16921 PreviousService =
"";
16922 ServiceAndRepeatNumTotal =
"";
16923 NumTrainsAtLoc = 0;
16925 NumPlatsAtThisLocCalculated =
false;
16929 if(Ptr2 == LocServiceTimesVector.end())
16934 if(Ptr2 == LocServiceTimesVector.end())
16938 while(Ptr2->Location == Ptr1->Location)
16940 if(Ptr1->FrhMarker ==
"Frh")
16943 Ptr1->FrhMarker =
"FrhCounted";
16945 PreviousService =
"";
16946 NumTrainsAtLoc = 0;
16947 ServiceAndRepeatNumTotal =
"";
16948 if((Ptr1->Location ==
"") && (Ptr2->Location ==
""))
16952 while((Ptr2->AtLocTime != Ptr1->AtLocTime) || ((Ptr1->AtLocTime ==
"") && (Ptr2->AtLocTime ==
"")))
16955 if(Ptr1->FrhMarker ==
"Frh")
16958 Ptr1->FrhMarker =
"FrhCounted";
16961 if(Ptr2 == LocServiceTimesVector.end())
16965 if(Ptr2->Location != Ptr1->Location)
16970 if(Ptr2 == LocServiceTimesVector.end())
16974 if(Ptr2->Location != Ptr1->Location)
16978 while(Ptr2->AtLocTime == Ptr1->AtLocTime)
16980 if((Ptr1->AtLocTime ==
"") && (Ptr2->AtLocTime ==
""))
16984 if(!NumPlatsAtThisLocCalculated)
16987 NumPlatsAtThisLocCalculated =
true;
16989 if(Ptr1->ServiceAndRepeatNum != PreviousService)
16991 if(ServiceAndRepeatNumTotal ==
"")
16993 ServiceAndRepeatNumTotal = Ptr1->ServiceAndRepeatNum;
16994 NumTrainsAtLoc = 1;
16998 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr1->ServiceAndRepeatNum;
17001 PreviousService = Ptr2->ServiceAndRepeatNum;
17002 if(ServiceAndRepeatNumTotal ==
"")
17004 ServiceAndRepeatNumTotal = Ptr2->ServiceAndRepeatNum;
17005 NumTrainsAtLoc = 1;
17009 ServiceAndRepeatNumTotal = ServiceAndRepeatNumTotal +
"," + Ptr2->ServiceAndRepeatNum;
17012 if(Ptr1->FrhMarker ==
"Frh")
17015 Ptr1->FrhMarker =
"FrhCounted";
17018 if((Ptr2 == LocServiceTimesVector.end()) || (Ptr2->Location != Ptr1->Location) || (Ptr2->AtLocTime != Ptr1->AtLocTime))
17022 ServiceAndRepeatNumTotalOutput =
ConsolidateSARNTAtLoc(1, ServiceAndRepeatNumTotal, NumTrainsAtLoc);
17024 if((NumTrainsAtLoc > 1) && ((FrhCount < NumTrainsAtLoc) || (FrhCount != LastFrhCount)))
17026 AnsiString Asterisk =
"";
17027 if(NumTrainsAtLoc > NumPlats)
17034 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << Ptr1->AtLocTime <<
"," << ServiceAndRepeatNumTotalOutput <<
'\n';
17036 else if(FrhCount == 1)
17038 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << Ptr1->AtLocTime <<
" (1 remains here)," << ServiceAndRepeatNumTotalOutput <<
'\n';
17042 TTFile3 << Asterisk << Ptr1->Location <<
"," << NumPlats <<
"," << NumTrainsAtLoc <<
"," << Ptr1->AtLocTime <<
" (" << FrhCount <<
" remain here)," << ServiceAndRepeatNumTotalOutput <<
'\n';
17044 LastFrhCount = FrhCount;
17045 PreviousServiceAndRepeatNumTotalOutput = ServiceAndRepeatNumTotalOutput;
17046 AtLocsPrinted =
true;
17047 ServiceAndRepeatNumTotal =
"";
17050 if(Ptr2 == LocServiceTimesVector.end())
17054 if(Ptr2->Location != Ptr1->Location)
17059 if(Ptr2 == LocServiceTimesVector.end())
17067 TTFile3 <<
"Nothing to report for trains at locations";
17069 TTFile3 <<
"\n\n\n";
17090 catch(
const Exception &e)
17092 AnsiString TTErrorFileName =
"Analysis Error.txt";
17093 TTErrorFileName = CurDir +
"\\Formatted timetables\\" + TTErrorFileName;
17094 std::ofstream TTError(TTErrorFileName.c_str());
17097 ShowMessage(
"Analysis error file failed to open - can't be created");
17101 AnsiString TimeNow = TDateTime::CurrentDateTime().FormatString(
"dd-mm-yyyy hh.nn.ss");
17102 TTError << TimeNow.c_str() <<
"\n" << ArrRange <<
"\n" << ArrChecked <<
"\n" << DepRange <<
"\n" <<
17103 DepChecked <<
"\n" << AtLocChecked <<
"\n" << AnsiString(e.Message);
17105 ShowMessage(
"Error in Conflict Analysis: A file called 'Analysis Error.txt' has been created in your Formatted timetables folder. Please send this file together with your railway and timetable files to railwayfeedback@gmail.com for investigation - many thanks");
17117 if((Time1 ==
"") || (Time2 ==
""))
17122 int Mins = Time1.SubString(4,2).ToInt();
17123 int Hours = Time1.SubString(1,2).ToInt();
17124 int Time1Mins = (Hours * 60) + Mins;
17125 Mins = Time2.SubString(4,2).ToInt();
17126 Hours = Time2.SubString(1,2).ToInt();
17127 int Time2Mins = (Hours * 60) + Mins;
17128 if(abs(Time1Mins - Time2Mins) <= MinuteRange)
17140 bool &AnalysisError,
int &MaxNumberOfSameDirections)
17147 AnsiString Output =
"", OneService =
"", TempStr1 =
"", TempStr2 =
"";
17149 std::list<AnsiString> ServiceList;
17151 bool EvenComma =
false;
17152 for(
int x = 1; x <= Input.Length(); x++)
17154 TempStr1 = Input[x];
17155 if(TempStr1 == AnsiString(
',') && EvenComma)
17161 TempStr2 += Input[x];
17163 if(TempStr1 == AnsiString(
','))
17165 EvenComma = !EvenComma;
17169 while(TempStr2.Length() > 0)
17171 SCPos = TempStr2.Pos(
';');
17174 OneService = TempStr2.SubString(1, SCPos - 1);
17175 ServiceList.push_back(OneService);
17176 TempStr2 = TempStr2.SubString(SCPos + 1, TempStr2.Length() - SCPos);
17180 ServiceList.push_back(TempStr2);
17184 ServiceList.sort();
17185 ServiceList.unique();
17186 NumTrainsAtLoc = ServiceList.size();
17189 int DirectionMarker = 0;
17191 std::list<AnsiString>::iterator SLIt, SLIt1, SLIt2, SLIt3;
17193 for(SLIt = ServiceList.begin(); SLIt != ServiceList.end(); SLIt++)
17195 *SLIt = *SLIt +
"&0";
17197 SLIt3 = ServiceList.end();
17199 AnsiString ServiceRef1, ServiceRef2, AnsiTime1, AnsiTime2, RepeatInfo1, RepeatInfo2;
17200 int AmpersandPos, SpacePos, CommaPos1, CommaPos2, RepeatNum1, RepeatNum2;
17201 TAllServiceCallingLocsMap::iterator ASCLIt1, ASCLIt2;
17203 MaxNumberOfSameDirections = 0;
17204 int SameDirectionCount = 0;
17206 for(std::list<AnsiString>::iterator SLIt1 = ServiceList.begin(); SLIt1 != SLIt3; SLIt1++)
17210 if(SLIt1->SubString(SLIt1->Length() - 1, 2) != AnsiString(
"&0"))
17216 CommaPos1 = SLIt1->Pos(
',');
17217 ServiceRef1 = SLIt1->SubString(1, CommaPos1 - 1);
17219 SpacePos = ServiceRef1.Pos(
' ');
17223 RepeatInfo1 = ServiceRef1.SubString(SpacePos + 2, ServiceRef1.Length() - SpacePos - 2);
17224 ServiceRef1 = ServiceRef1.SubString(1, SpacePos - 1);
17225 if(RepeatInfo1[1] ==
'F')
17231 SpacePos = RepeatInfo1.Pos(
' ');
17232 RepeatNum1 = RepeatInfo1.SubString(SpacePos + 1, RepeatInfo1.Length() - SpacePos).ToInt();
17235 AnsiTime1 = SLIt1->SubString(CommaPos1 + 1, SLIt1->Length() - CommaPos1);
17237 AmpersandPos = AnsiTime1.Pos(
'&');
17238 AnsiTime1 = AnsiTime1.SubString(1, AmpersandPos - 1);
17243 throw Exception(
"ASCLIt1 Error in " + Input);
17245 ServiceCallingLocsList1 = ASCLIt1->second;
17246 AmpersandPos = SLIt1->Pos(
'&');
17247 *SLIt1 = SLIt1->SubString(1, AmpersandPos);
17248 *SLIt1 = *SLIt1 + AnsiString(++DirectionMarker);
17250 SameDirectionCount = 1;
17251 for(SLIt2 = SLIt; SLIt2 != ServiceList.end(); SLIt2++)
17253 CommaPos2 = SLIt2->Pos(
',');
17254 ServiceRef2 = SLIt2->SubString(1, CommaPos2 - 1);
17256 SpacePos = ServiceRef2.Pos(
' ');
17260 RepeatInfo2 = ServiceRef2.SubString(SpacePos + 2, ServiceRef2.Length() - SpacePos - 2);
17261 ServiceRef2 = ServiceRef2.SubString(1, SpacePos - 1);
17262 if(RepeatInfo2[1] ==
'F')
17268 SpacePos = RepeatInfo2.Pos(
' ');
17269 RepeatNum2 = RepeatInfo2.SubString(SpacePos + 1, RepeatInfo2.Length() - SpacePos).ToInt();
17272 AnsiTime2 = SLIt2->SubString(CommaPos2 + 1, SLIt2->Length() - CommaPos2);
17274 AmpersandPos = AnsiTime2.Pos(
'&');
17275 AnsiTime2 = AnsiTime2.SubString(1, AmpersandPos - 1);
17280 throw Exception(
"ASCLIt2 Error in " + Input);
17282 ServiceCallingLocsList2 = ASCLIt2->second;
17284 if(
SameDirection(0, ServiceRef1, ServiceRef2, AnsiTime1, AnsiTime2, RepeatNum1, RepeatNum2, ServiceCallingLocsList1, ServiceCallingLocsList2, Location, Arrival))
17286 int AmpersandPos = SLIt2->Pos(
'&');
17287 *SLIt2 = SLIt2->SubString(1, AmpersandPos);
17288 *SLIt2 = *SLIt2 + AnsiString(DirectionMarker);
17289 SameDirectionCount++;
17292 if(SameDirectionCount > MaxNumberOfSameDirections)
17294 MaxNumberOfSameDirections = SameDirectionCount;
17299 if(SLIt3->SubString(SLIt3->Length() - 1, 2) == AnsiString(
"&0"))
17302 AmpersandPos = SLIt3->Pos(
'&');
17303 *SLIt3 = SLIt3->SubString(1, AmpersandPos);
17304 *SLIt3 = *SLIt3 + AnsiString(++DirectionMarker);
17307 for(SLIt = ServiceList.begin(); SLIt != ServiceList.end(); SLIt++)
17310 AmpersandPos = SLIt->Pos(
'&');
17311 AnsiString DirectionMarkerString = SLIt->SubString(AmpersandPos + 1, SLIt->Length() - AmpersandPos);
17312 AnsiString ServiceWithoutMarker = SLIt->SubString(1, AmpersandPos - 1);
17313 DirectionMarker = DirectionMarkerString.ToInt();
17314 AnsiString DirectionSuffix =
"";
17316 if(DirectionMarker < 27)
17318 c = 64 + DirectionMarker;
17319 DirectionSuffix =
"," + AnsiString(c);
17321 else if(DirectionMarker < 53)
17323 c = 65 + DirectionMarker - 27;
17324 DirectionSuffix =
",A" + AnsiString(c);
17328 DirectionSuffix =
",?";
17330 *SLIt = ServiceWithoutMarker + DirectionSuffix;
17333 for(SLIt = ServiceList.begin(); SLIt != ServiceList.end(); SLIt++)
17335 Output = Output + *SLIt +
",";
17337 if(Output.Length() > 0)
17339 Output = Output.SubString(1, Output.Length() - 1);
17345 catch(
const Exception &e)
17347 AnalysisError =
true;
17359 AnsiString InternalInput = Input, Output =
"", OneService =
"";
17361 std::list<AnsiString> ServiceList;
17363 while(InternalInput.Length() > 0)
17365 CommaPos = InternalInput.Pos(
',');
17368 OneService = InternalInput.SubString(1, CommaPos - 1);
17369 ServiceList.push_back(OneService);
17370 InternalInput = InternalInput.SubString(CommaPos + 1, InternalInput.Length() - CommaPos);
17374 ServiceList.push_back(InternalInput);
17375 InternalInput =
"";
17379 ServiceList.sort();
17380 ServiceList.unique();
17381 NumTrainsAtLoc = ServiceList.size();
17382 for(std::list<AnsiString>::iterator SLIt = ServiceList.begin(); SLIt != ServiceList.end(); SLIt++)
17384 Output = Output + *SLIt +
",";
17386 if(Output.Length() > 0)
17388 Output = Output.SubString(1, Output.Length() - 1);
17401 AnsiString(RepeatNum1) +
"," + AnsiString(RepeatNum2) +
"," + Location);
17403 std::list<AnsiString>::iterator LP1 = 0, LP2 = 0, ListPtr1 = 0, ListPtr2 = 0, LocPtr1 = 0, LocPtr2 = 0;
17408 bool LocFound =
false;
17409 AnsiString Ref1 = Ref1In, Ref2 = Ref2In;
17411 TDateTime FirstServiceTime;
17414 int Ref1Target = 0, Ref1Count = 0;
17415 int SlashPos = Ref1.Pos(
'/');
17418 Ref1Target = Ref1.SubString(SlashPos + 1, Ref1.Length() - SlashPos).ToInt();
17419 Ref1 = Ref1.SubString(1, SlashPos - 1);
17421 int Ref2Target = 0, Ref2Count = 0;
17422 SlashPos = Ref2.Pos(
'/');
17425 Ref2Target = Ref2.SubString(SlashPos + 1, Ref2.Length() - SlashPos).ToInt();
17426 Ref2 = Ref2.SubString(1, SlashPos - 1);
17428 for(ListPtr1 = List1.begin(); ListPtr1 != List1.end(); ListPtr1++)
17431 if((*ListPtr1) == Location)
17433 LocPtr1 = ListPtr1;
17436 if(ListPtr1->SubString(1, 3) ==
"%%%")
17438 AnsiString CDTTime = ListPtr1->SubString(4, 5);
17443 FirstServiceTime = TDateTime(-1);
17444 bool BreakFlag =
false;
17447 if(TDVIt->ServiceReference == Ref1)
17449 if(Ref1Target > Ref1Count)
17454 IncMinutes = TDVIt->ActionVector.back().RearStartOrRepeatMins;
17455 for(TActionVector::iterator AVIt = TDVIt->ActionVector.begin(); AVIt != TDVIt->ActionVector.end(); AVIt++)
17459 FirstServiceTime = AVIt->EventTime;
17465 FirstServiceTime = AVIt->ArrivalTime;
17471 FirstServiceTime = AVIt->DepartureTime;
17482 if(IncMinutes == -1)
17484 throw Exception(
"Failed to find service for ServiceRef1 in SameDirection " + Ref1In +
" " + Ref2In +
" " + Time1 +
" " + Time2 +
" " + AnsiString(RepeatNum1) +
" " + AnsiString(RepeatNum2) +
" " + Location);
17486 if(FirstServiceTime == TDateTime(-1))
17488 throw Exception(
"Failed to find first service time for ServiceRef1 in SameDirection " + Ref1In +
" " + Ref2In +
" " + Time1 +
" " + Time2 +
" " + AnsiString(RepeatNum1) +
" " + AnsiString(RepeatNum2) +
" " + Location);
17492 if(!Arrival && (Time1 == CDTTime))
17497 if(Arrival && (Time1 == CDTTime))
17501 if(Time1 > CDTTime)
17506 if(Time1 < CDTTime)
17519 for(ListPtr2 = List2.begin(); ListPtr2 != List2.end(); ListPtr2++)
17521 if((*ListPtr2) == Location)
17523 LocPtr2 = ListPtr2;
17526 if(ListPtr2->SubString(1, 3) ==
"%%%")
17528 AnsiString CDTTime = ListPtr2->SubString(4, 5);
17533 FirstServiceTime = TDateTime(-1);
17534 bool BreakFlag =
false;
17537 if(TDVIt->ServiceReference == Ref2)
17539 if(Ref2Target > Ref2Count)
17544 IncMinutes = TDVIt->ActionVector.back().RearStartOrRepeatMins;
17545 for(TActionVector::iterator AVIt = TDVIt->ActionVector.begin(); AVIt != TDVIt->ActionVector.end(); AVIt++)
17549 FirstServiceTime = AVIt->EventTime;
17555 FirstServiceTime = AVIt->ArrivalTime;
17561 FirstServiceTime = AVIt->DepartureTime;
17572 if(IncMinutes == -1)
17574 throw Exception(
"IncMinutes -1 for ServiceRef2 in SameDirection " + Ref1In +
" " + Ref2In +
" " + Time1 +
" " + Time2 +
" " + AnsiString(RepeatNum1) +
" " + AnsiString(RepeatNum2) +
" " + Location);
17576 if(FirstServiceTime == TDateTime(-1))
17578 throw Exception(
"First service time -1 for ServiceRef2 in SameDirection " + Ref1In +
" " + Ref2In +
" " + Time1 +
" " + Time2 +
" " + AnsiString(RepeatNum1) +
" " + AnsiString(RepeatNum2) +
" " + Location);
17582 if(!Arrival && (Time2 == CDTTime))
17587 if(Arrival && (Time2 == CDTTime))
17591 if(Time2 > CDTTime)
17596 if(Time2 < CDTTime)
17611 LP1 = List1.begin();
17613 for(ListPtr1 = LocPtr1; ListPtr1 != LP1; ListPtr1--)
17615 if(ListPtr1 == List1.begin())
17619 if(ListPtr1->SubString(1, 3) ==
"%%%")
17626 LP2 = List2.begin();
17628 for(ListPtr2 = LocPtr2; ListPtr2 != LP2; ListPtr2--)
17630 if(ListPtr2 == List2.begin())
17634 if(ListPtr2->SubString(1, 3) ==
"%%%")
17644 for(ListPtr1 = LP1; ListPtr1 != List1.end(); ListPtr1++)
17646 if(ListPtr1 == LocPtr1)
17650 if(ListPtr1->SubString(1, 3) ==
"%%%")
17654 for(ListPtr2 = LP2; ListPtr2 != List2.end(); ListPtr2++)
17656 if(ListPtr2 == LocPtr2)
17660 if(ListPtr2->SubString(1, 3) ==
"%%%")
17664 if((*ListPtr1) == (*ListPtr2))
17681 for(ListPtr1 = LP1; ListPtr1 != List1.end(); ListPtr1++)
17683 if(ListPtr1 == List1.end())
17687 if(ListPtr1->SubString(1, 3) ==
"%%%")
17691 for(ListPtr2 = LP2; ListPtr2 != List2.end(); ListPtr2++)
17693 if(ListPtr2 == List2.end())
17697 if(ListPtr2->SubString(1, 3) ==
"%%%")
17701 if((*ListPtr1) == (*ListPtr2))
17718 if(ExitList.empty())
17724 AnsiString ExitLocList =
"";
17727 unsigned int Counter = 0;
17732 if(((Counter % 6) == 0) && (Counter < (ExitList.size() - 1)))
17734 ExitLocList +=
"\n";
17737 if(StartName ==
"")
17739 if(ExitList.size() == 1)
17743 return(
" at " + ID);
17748 if(ExitList.size() < 4)
17750 AllowedExits =
",\nallowable exit element(s): " + ExitLocList;
17755 AllowedExits =
",\nallowable exit element(s):\n" + ExitLocList;
17765 if(ExitList.size() < 4)
17767 AllowedExits =
",\nallowable exit element(s): " + ExitLocList;
17772 AllowedExits =
",\nallowable exit element(s):\n" + ExitLocList;
17778 if(ExitList.size() < 4)
17780 AllowedExits =
",\nallowable exit element(s): " + ExitLocList;
17781 return(
" at " + StartName);
17785 AllowedExits =
",\nallowable exit element(s):\n" + ExitLocList;
17786 return(
" at " + StartName);
17826 AnsiString FormatStr =
"####0.0";
17827 AnsiString AvLateArrMins =
"";
17828 AnsiString AvEarlyArrMins =
"";
17829 AnsiString AvLatePassMins =
"";
17830 AnsiString AvEarlyPassMins =
"";
17831 AnsiString AvLateDepMins =
"";
17853 PerfFile <<
'\n' <<
'\n' <<
"***************************************";
17854 PerfFile <<
'\n' <<
'\n' <<
"Performance summary:" <<
'\n';
17866 PerfFile <<
LateArrivals <<
" late arrivals (average " << AvLateArrMins.c_str() <<
" min)" <<
'\n';
17870 PerfFile <<
LateArrivals <<
" late arrival (" << AvLateArrMins.c_str() <<
" min)" <<
'\n';
17878 PerfFile <<
EarlyArrivals <<
" early arrivals (average " << AvEarlyArrMins.c_str() <<
" min)" <<
'\n';
17882 PerfFile <<
EarlyArrivals <<
" early arrival (" << AvEarlyArrMins.c_str() <<
" min)" <<
'\n';
17890 PerfFile <<
OnTimePasses <<
" on-time passes" <<
'\n';
17898 PerfFile <<
LatePasses <<
" late passes (average " << AvLatePassMins.c_str() <<
" min)" <<
'\n';
17902 PerfFile <<
LatePasses <<
" late pass (" << AvLatePassMins.c_str() <<
" min)" <<
'\n';
17906 PerfFile <<
LatePasses <<
" late passes" <<
'\n';
17910 PerfFile <<
EarlyPasses <<
" early passes (average " << AvEarlyPassMins.c_str() <<
" min)" <<
'\n';
17914 PerfFile <<
EarlyPasses <<
" early pass (" << AvEarlyPassMins.c_str() <<
" min)" <<
'\n';
17918 PerfFile <<
EarlyPasses <<
" early passes" <<
'\n';
17922 PerfFile <<
OnTimeDeps <<
" on-time departures" <<
'\n';
17926 PerfFile <<
OnTimeDeps <<
" on-time departure" <<
'\n';
17930 PerfFile <<
LateDeps <<
" late departures (average " << AvLateDepMins.c_str() <<
" min)" <<
'\n';
17934 PerfFile <<
LateDeps <<
" late departure (" << AvLateDepMins.c_str() <<
" min)" <<
'\n';
17938 PerfFile <<
LateDeps <<
" late departures" <<
'\n';
17940 TDateTime TempExcessLCDownTime;
17954 if(TempExcessLCDownTime > TDateTime(0))
17960 AnsiString FormattedExcessLCDownMins = FormatFloat(FormatStr,
ExcessLCDownMins);
17964 PerfFile << FormattedExcessLCDownMins.c_str() <<
" excess minutes of level crossing barrier down time" <<
'\n';
17968 PerfFile <<
MissedStops <<
" missed stops" <<
'\n';
17972 PerfFile <<
MissedStops <<
" missed stop" <<
'\n';
18000 PerfFile <<
NumFailures <<
" train failures" <<
'\n';
18004 PerfFile <<
NumFailures <<
" train failure" <<
'\n';
18010 PerfFile <<
AvHoursIntValue <<
" hour mean time betweeen train failures" <<
'\n';
18014 PerfFile <<
AvHoursIntValue <<
" hours mean time betweeen train failures" <<
'\n';
18017 AnsiString AvLateMinsLocsNotReached =
"";
18023 if(LocsNotReached > 0)
18026 PerfFile << LocsNotReached <<
" locations that trains failed to reach (average lateness " << AvLateMinsLocsNotReached.c_str() <<
" min)" <<
'\n';
18030 PerfFile <<
SPADRisks <<
" SPAD risks" <<
'\n';
18034 PerfFile <<
SPADRisks <<
" SPAD risk" <<
'\n';
18046 PerfFile <<
Derailments <<
" derailments" <<
'\n';
18050 PerfFile <<
Derailments <<
" derailment" <<
'\n';
18060 PerfFile <<
'\n' <<
"***************************************" <<
'\n';
18062 bool DerailSPADFlag =
false, CrashFlag =
false;
18064 int OverallScorePercent = 100;
18066 double TotLateMinsFactor = 1;
18067 double MissedStopAndSPADRiskFactor = 1;
18068 double NetNegFactor = 1;
18077 OverallScorePercent = 5;
18078 DerailSPADFlag =
true;
18082 OverallScorePercent = 0;
18085 if(OverallScorePercent == 100)
18089 TotLateMinsFactor =
18097 NetNegFactor = TotLateMinsFactor * MissedStopAndSPADRiskFactor;
18099 OverallScorePercent = 100 * NetNegFactor;
18102 if((TotArrDep > 0) || DerailSPADFlag || CrashFlag)
18105 AnsiString OneFailureString =
", though the failure would account for some poor performance";
18106 AnsiString TwoOrMoreFailureString =
", though the failures would account for some poor performance";
18107 AnsiString AddedString =
"";
18110 AddedString = OneFailureString;
18114 AddedString = TwoOrMoreFailureString;
18116 PerfFile <<
"\nOverall score: " << OverallScorePercent <<
"%\n";
18117 AnsiString Rating =
"";
18118 if(OverallScorePercent == 100)
18120 Rating =
"Perfect!";
18122 else if(OverallScorePercent >= 95)
18124 Rating =
"Excellent";
18126 else if(OverallScorePercent >= 90)
18128 Rating =
"Very good";
18130 else if(OverallScorePercent >= 80)
18134 else if(OverallScorePercent >= 70)
18138 else if(OverallScorePercent >= 60)
18140 Rating =
"Unacceptable" + AddedString;
18142 else if(OverallScorePercent >= 50)
18144 Rating =
"Poor" + AddedString;
18146 else if(OverallScorePercent >= 40)
18148 Rating =
"Bad" + AddedString;
18150 else if(OverallScorePercent >= 30)
18152 Rating =
"Very bad" + AddedString;
18154 else if(OverallScorePercent >= 20)
18156 Rating =
"Terrible" + AddedString;
18158 else if(OverallScorePercent >= 10)
18160 Rating =
"Appalling" + AddedString;
18162 else if(OverallScorePercent >= 5)
18166 Rating =
"Disastrous - potential loss of life";
18171 Rating =
"Dire" + AddedString;
18174 else if(OverallScorePercent < 5)
18178 Rating =
"Catastrophic - loss of life";
18182 Rating =
"Abysmal";
18185 PerfFile <<
"Overall rating: " << Rating.c_str() <<
'\n';
18189 PerfFile <<
"\nThere were no timetabled departures or arrivals so there is insufficient information to provide a performance score or rating" <<
'\n';
18191 PerfFile <<
'\n' <<
"***************************************";
18200 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
18250 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
18285 int IncrementalMinutes = 0;
18299 bool TrainOperatingFlag =
false;
18304 TrainOperatingFlag =
true;
18308 if(TrainOperatingFlag)
18316 for(
unsigned int z = 0; z < TDEntry.
ActionVector.size(); z++)
18363 AnsiString HeadCode;
18367 for(
unsigned int x = 0; x <
TrainVector.size(); x++)
18371 HCandTrainPosParam.first = HeadCode;
18372 HCandTrainPosParam.second = TrainID;
18374 if((TimeToAct >= 0) && (TimeToAct < 59.9))
18377 OpTimeToActMultiMapEntry.first = TimeToAct;
18378 OpTimeToActMultiMapEntry.second = HCandTrainPosParam;
18407 float TimeToAct = 0;
18408 int DistanceToRedSignal = 0;
18411 ContinuationEntryVecPosVector.clear();
18412 bool LaterTrain =
false;
18416 LaterTrain =
false;
18417 if(CTEIt->second.TrainDataEntryPtr->TrainOperatingDataVector.at(CTEIt->second.RepeatNumber).RunningEntry !=
NotStarted)
18428 if(!ContinuationEntryVecPosVector.empty())
18430 for(
unsigned int x = 0; x < ContinuationEntryVecPosVector.size(); x++)
18432 if(CTEIt->second.VectorPosition == ContinuationEntryVecPosVector.at(x))
18446 ContinuationEntryVecPosVector.push_back(CTEIt->second.VectorPosition);
18447 AnsiString HeadCode = CTEIt->second.HeadCode;
18448 float CurrentStopTime;
18449 float LaterStopTime;
18450 float RecoverableTime;
18453 bool SigControlAndCanPassRedSignal =
false;
18457 SigControlAndCanPassRedSignal, &CTEIt->second.TrainDataEntryPtr->ActionVector.at(1),
18459 HeadCode, TrainID, CurrentStopTime, LaterStopTime, RecoverableTime, AvTrackSpeed);
18462 if(AvTrackSpeed < 30)
18466 if(DistanceToRedSignal == -1)
18472 int Speed = AvTrackSpeed;
18473 int MaxSpeed = int(CTEIt->second.TrainDataEntryPtr->MaxRunningSpeed);
18474 if(AvTrackSpeed > MaxSpeed)
18478 if(CTEIt->second.TrainDataEntryPtr->ActionVector.at(1).SignallerControl)
18481 Speed = CTEIt->second.TrainDataEntryPtr->SignallerSpeed;
18484 TimeToAct = LaterStopTime + DistanceToRedSignal * 3.6 / 60 / Speed;
18489 float MinsBefEnter = double(CTEIt->first -
TTClockTime) * 86400.0 / 60.0;
18490 TimeToAct += MinsBefEnter;
18493 HCandTrainPosParam.first = HeadCode;
18494 HCandTrainPosParam.second = -1 - CTEIt->second.VectorPosition;
18497 if(TimeToAct < 59.9)
18499 OpTimeToActMultiMapEntry.first = TimeToAct;
18500 OpTimeToActMultiMapEntry.second = HCandTrainPosParam;
18512 bool SigControlAndCanPassRedSignal,
TActionVectorEntry *AVPtr, AnsiString HeadCode,
int TrainID,
float &CurrentStopTime,
float &LaterStopTime,
18513 float &RecoverableTime,
int &AvTrackSpeed)
18522 AnsiString(TrackVectorPositionEntryPos) +
", " + AVPtr->
Command);
18523 int DistanceToRedSignal = 0;
18524 int CumTrackSpeed = 0;
18526 int TrackSpeedCount = 0;
18536 int CurrentElement = TrackVectorPosition;
18537 int CurrentEntryPos = TrackVectorPositionEntryPos;
18542 CurrentStopTime = 0;
18544 RecoverableTime = 0;
18545 if(CurrentElement == -1)
18550 int CurrentExitPos;
18555 if((CurrentEntryPos == 0) || (CurrentEntryPos == 2))
18559 CurrentExitPos = 1;
18563 CurrentExitPos = 3;
18568 CurrentExitPos = 0;
18604 CurrentStopTime = float(TimeToDepart);
18610 if((CurrentExitConfig ==
Signal) && (CurrentAttribute == 0))
18621 else if(SigControlAndCanPassRedSignal)
18626 if((NextEntryPos == 0) || (NextEntryPos == 2))
18647 CurrentElement = NextElement;
18648 CurrentEntryPos = NextEntryPos;
18649 CurrentExitPos = NextExitPos;
18661 int LaterStopNumber = 0;
18665 while(!((CurrentExitConfig ==
Signal) && (CurrentAttribute == 0)))
18674 if(CurrentEntryPos > 1)
18694 bool StopRequired =
false;
18711 int TrainOnElement;
18718 if(CurrentEntryPos > 1)
18727 if((TrainOnElement > -1) && (TrainOnElement != TrainID))
18736 double StopTimeDouble;
18749 if(StopTimeDouble < 0.5)
18751 StopTimeDouble = 0.5;
18755 LaterStopTime += float(StopTimeDouble);
18756 RecoverableTime += StopTimeDouble - 0.5;
18757 if((LaterStopNumber == 1) && (TrainID > -1))
18765 if((AVPtr + 1)->FormatType ==
TimeLoc)
18769 StopTimeDouble = double((AVPtr + 1)->DepartureTime - AVPtr->
ArrivalTime) * 86400.0 / 60.0;
18771 if(StopTimeDouble < 0.5)
18773 StopTimeDouble = 0.5;
18776 LaterStopTime += float(StopTimeDouble);
18777 RecoverableTime += StopTimeDouble - 0.5;
18778 if((LaterStopNumber == 1) && (TrainID > -1))
18794 if(NextElement == -1)
18803 if((NextEntryPos == 0) || (NextEntryPos == 2))
18824 CurrentElement = NextElement;
18825 CurrentEntryPos = NextEntryPos;
18826 CurrentExitPos = NextExitPos;
18830 if((CurrentExitConfig ==
Signal) && (CurrentAttribute == 0))
18845 float MaxAllowableSpeed;
18847 if(TrackSpeedCount > 0)
18849 MaxAllowableSpeed = CumTrackSpeed / TrackSpeedCount;
18853 if(CurrentEntryPos > 1)
18863 float KmPerLocationStop;
18865 if(LaterStopNumber > 0)
18867 KmPerLocationStop = float(DistanceToRedSignal) / LaterStopNumber / 1000;
18868 AvTrackSpeed = (8.75 * KmPerLocationStop) + 44;
18872 AvTrackSpeed = (sqrt(
float(DistanceToRedSignal) / 1000) * 44) + 60;
18876 if(AvTrackSpeed > MaxAllowableSpeed)
18878 AvTrackSpeed = MaxAllowableSpeed;
18881 return(DistanceToRedSignal);